【问题标题】:Error on running build command through npm run for reactjs project通过 npm run 为 reactjs 项目运行构建命令时出错
【发布时间】:2020-05-14 09:29:51
【问题描述】:

运行“craco build”时出错

执行命令:

npm run dist

如果我从同一个文件夹运行npm run build,也会出现同样的错误。

package.json 文件中的命令:

"scripts": {
    "start": "npm run storybook:start",
    "dev": "craco start",
    "build": "craco build",
    "dist": "npm run build && del-cli build/*.* build/fonts",
    "test": "craco test",
    "lint": "eslint . --ext .js,.jsx --ignore-path .gitignore",
    "eject": "react-scripts eject",
-----------------

错误输出

craco build

'craco' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1

如果我通过运行 npm info craco version 检查 craco 版本,那么我会收到 0.0.3。 我正在运行 node v8.0.0,npm 版本是 5.0.0

由于某些项目特定条件,我在节点 v8.0.0 上。

【问题讨论】:

  • 当我的 node_modules 文件夹为空时,我遇到了同样的错误。必须运行 yarn install。
  • 你能尝试安装craco吗。我执行了“npm install @craco/craco”,它的错误消失了。

标签: node.js reactjs npm build craco


【解决方案1】:

使用这个命令

npm install @craco/craco --save

【讨论】:

  • 没用。它已经在 package.json 中,名称为 "@craco/craco": "^6.1.1",但在 Windows 上仍然无法识别,仅在 Linux 上 (yarn start)
  • 我在我的 pakeage.json 中有它,但我仍然必须通过发出 npm install @craco/craco --save 来安装它
  • 顺便说一句,如果你仍然有同样的问题,你可以使用最后一个版本 o tailwind 它不需要 craco
猜你喜欢
  • 1970-01-01
  • 2017-12-28
  • 1970-01-01
  • 2011-08-19
  • 2021-08-10
  • 1970-01-01
  • 2021-05-04
  • 2014-08-01
  • 1970-01-01
相关资源
最近更新 更多