create-next-app 项目:当 运行ning “ npm 运行 build ” 时无法识别 react-script

create-next-app project : react-script is not recognized when running " npm run build "

这是我的 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 显示此错误。

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

"build": "react-scripts build",

这样做:

"build": "next build",