next.js教程,错误运行Next.js Dev Server(NPM Run Dev)

发布于 2025-02-12 15:41:06 字数 1656 浏览 1 评论 0原文

我正在做启动器Next.js tutorial < /a>并在尝试运行下一个开发服务器并运行我的应用时遇到错误。

这是我的软件包文件包含的内容:

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

运行npm运行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

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

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

花之痕靓丽 2025-02-19 15:41:06

我将我的节点版本v11.15.1更新为v12.22.1,然后已解决

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

回心转意 2025-02-19 15:41:06

我更新了我的节点版V10-&gt; v16。它的工作

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

心不设防 2025-02-19 15:41:06

是的,更新您的节点版本将解决此问题。

在执行此操作之前,请在项目中删除 node_modules 文件夹。

然后,要将节点更新为最新稳定版本,请在终端上运行以下命令:

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

您可能需要重新启动终端以查看您检查的版本更新,

node -v

然后使用以下方式使用:然后使用:

npm install

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
酒废 2025-02-19 15:41:06
  1. 基本上我有多个节点。

  2. 可以通过 nvm

  3. 使用命令通过 nvm

    切换到节点14:

    节点使用14.15.0

  1. Basically I have multiple versins of node.

  2. It is possible through nvm

  3. I switched to node 14 using the command :

    node use 14.15.0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文