【问题标题】:create-next-app project : react-script is not recognized when running " npm run build "create-next-app 项目:运行“npm run build”时无法识别反应脚本
【发布时间】:2021-11-28 06:34:59
【问题描述】:

这是我的 package.json 文件:

  "name": "food-recipe",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "react-scripts build",
    "start": "next start"
  },
  "dependencies": {
    "@contentful/rich-text-react-renderer": "^15.4.0",
    "contentful": "^9.0.3",
    "next": "11.1.2",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  }
}

当我运行时:npm build 显示此错误。

【问题讨论】:

  • 尝试使用npm i --save react-scripts安装它
  • 我做到了,但出现了另一个错误:找不到所需的文件。名称:index.html
  • react-scripts 用于 CRA 应用程序。在 Next.js 应用程序中,您应该改用 next build。
  • 我从头开始重建了应用程序,但出现了不同的错误。你能看看我在这里发布的问题。 stackoverflow.com/questions/69505993/…

标签: reactjs npm next.js package.json


【解决方案1】:

使用 create-next-app 时不需要 react-scripts 而不是:

"build": "react-scripts build",

这样做:

"build": "next build",

【讨论】:

    猜你喜欢
    • 2020-12-03
    • 2018-01-21
    • 1970-01-01
    • 2019-11-15
    • 2017-10-05
    • 2019-04-27
    • 2021-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多