Next.js tutorial, error running Next.js dev server (npm run dev)

Viewed 663

I'm doing the starter Next.js tutorial and encountering an error when I try to run the Next dev server and run my app.

Here is what my package.json file contains:

{
  "scripts": {
      "dev": "next dev"
  },
  "dependencies": {
    "next": "^12.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

When running npm run dev, I get the following error:

> @ dev /Users/renaudj/Documents/Projects/next-app
> next dev

/Users/renaudj/Documents/Projects/next-app/node_modules/next/dist/trace/report/index.js:14
    reporters = [];
              ^

SyntaxError: Unexpected token =
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `next dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/renaudj/.npm/_logs/2022-07-04T05_09_15_196Z-debug.log

Anyone know what I'm missing here? Thank you!

3 Answers

I update my node version V11.15.1 to V12.22.1 then it's solved

I update my node version V10->V16. it' work

Yes, updating your version of node will solve this issue.

Before doing this, delete the node_modules folder in your project.

Then to update node to the latest stable version, run the following command on your terminal:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

You may need to restart your terminal to see the version update which you check using:

node -v

Then reinstall your project using

npm install
Related