I am attempting to use NextJS and I am run the command npm run build but it says next command cant be found. I re-install next globally this time (npm i -g next) and the net command is found but is then throwing an error saying "unexpected token '?'"
The complete error is:
/usr/local/lib/node_modules/next/dist/build/index.js:440
...pageKeys.app ?? []
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/local/lib/node_modules/next/dist/cli/next-build.js:15:55)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
I have attached a photo of all of the context if that helps.
Photo of the error plus context
I have tried to install next globally by adding -g to the npm install command and it fixed the first step of the problem I guess which was the next command not being found but then created another problem as stated previously. I am expecting Tovy to completely build but it can't because of the error.