Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unexpected token Error while upgrading react in nextjs app

I want to upgrade to React 18 in nextjs app. I followed instructions in official docs.

npm install next@latest react@latest react-dom@latest

But when I try to run npm run build I get the error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

/node_modules/next/dist/build/index.js:329
                    ...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)

I’ve tried to google this error, but there was no luck

>Solution :

Current next.js (13.0.0) requires node 14.6.0 or newer:

System Requirements

  • Node.js 14.6.0 or later
  • MacOS, Windows (including WSL), and Linux are supported

The error you see is because some of the jext.js code is using a nullish coalescing operator, introduced in node 14.0.0.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading