Next.js在所有npm运行命令中提供了丢失的脚本

时间:2019-07-19 18:22:15

标签: reactjs next

在Udemy类中,我正在创建一个Next.js项目。我有以下package.json

{
  "name": "nextjsdemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "next": "^9.0.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6"
  }
}

我的目录结构如下。

enter image description here

npm install --save next react react-dom

当我运行命令

npm run dev

我收到错误:

npm ERR! missing script: dev

我在npm run build上也收到类似的错误。

我做错了什么?

谢谢

编辑1 我可以使它起作用的唯一方法是在V4.2.3之前降级。最新版本不起作用似乎很奇怪。

1 个答案:

答案 0 :(得分:0)

此问题的解决方案是遵循github.com/zeit/next.js/#setup上的设置。