Next.js 在所有 npm run 命令上给出了缺失的脚本 [英] Next.js gives missing script on all npm run commands

查看:49
本文介绍了Next.js 在所有 npm run 命令上给出了缺失的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 Next.js 项目,因为我正在 Udemy 课程中学习.我有以下 package.json

I am creating a Next.js project as I follow along in a Udemy class. I have the following 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"
  }
}

我的目录结构如下.

npm install --save next react react-dom

当我运行命令时

npm run dev

我收到错误:

npm ERR! missing script: dev

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

I receive a similar error on npm run build as well.

我做错了什么?

谢谢,

编辑 1我可以让它工作的唯一方法是降级到 V4.2.3.最新版本不起作用,这似乎很奇怪.

Edit 1 The only way I could get this to work was to downgrade next to V4.2.3. This seems strange that the latest version does not work.

推荐答案

此问题的解决方案是按照 github.com/zeit/next.js/#setup.

The solution to this issue was to follow the setup on github.com/zeit/next.js/#setup.

这篇关于Next.js 在所有 npm run 命令上给出了缺失的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆