在执行 npm run dev 时,nextjs 的 React 给出错误

Mus*_*cks 2 reactjs next.js

在这里输入图像描述我全新安装了react(npx create-next-app),但它给了我这个错误......

PS C:\Users\Admin\Desktop\games> npm run start

games@0.1.0 开始 下次开始

  • 准备好在 [::]:3000 上启动服务器,url: http://localhost:3000 [错误:ENOENT: 没有这样的文件或目录,打开 'C:\Users\Admin\Desktop\games.next\BUILD_ID'] {错误号:-4058,代码:'ENOENT',系统调用:'打开',路径:'C:\ Users \ Admin \ Desktop \ games \ .next \ BUILD_ID'}

重新下载,更新node js...

小智 5

我认为您忘记构建代码了。

你应该npm run build在做之前先跑npm run start。因为npm run start使用“.next”文件夹中的代码来运行,而不是“src”文件夹中的原始代码。

您可能想改用“npm run dev”。因为你似乎正处于开发阶段。这将使用“src”文件夹中的代码来运行。