Next.js 教程,运行 Next.js 开发服务器时出错 (npm run dev)

Jos*_*osh 6 node.js npm next.js

我正在执行入门 Next.js 教程,当我尝试运行 Next 开发服务器并运行我的应用程序时遇到错误。

这是我的 package.json 文件包含的内容:

{
  "scripts": {
      "dev": "next dev"
  },
  "dependencies": {
    "next": "^12.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

运行时npm run dev,我收到以下错误:

> @ 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
Run Code Online (Sandbox Code Playgroud)

有人知道我在这里缺少什么吗?谢谢你!

小智 8

我将我的节点版本 V11.15.1 更新到 V12.22.1 然后就解决了