繁体   English   中英

如何解决 sh: react-scripts: command not found?

[英]How to resolve sh: react-scripts: command not found?

我使用 create-react-app 来生成一个应用程序。

create-react-app myapp

当我运行 yarn start 或 npm start 时,出现此错误:

反应脚本开始

sh:react-scripts:找不到命令 npm ERR! 文件 sh npm 错误! 代码 ELIFECYCLE npm ERR! errno ENOENT npm 错误! 系统调用产生 npm ERR! myapp@0.1.0 开始: react-scripts start npm ERR! 生成 ENOENT npm ERR! npm 错误! 在 myapp@0.1.0 启动脚本中失败。 npm 错误! 这可能不是 npm 的问题。 上面可能有额外的日志输出。

当我运行 npm ls 时反应:

myapp@0.1.0 /Users/johnno/foosball 
└── react@16.2.0

反应脚本存在。

这是我的 package.json:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-scripts": "1.0.17",
    "redux": "^3.7.2",
    "yarn": "^1.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

我尝试了this的建议,但无济于事。 我该如何解决这个问题?

我通过删除解决了这个问题

node_modules
纱锁
manifest_lock.json

和安装的软件包

npm install

要么

yarn

以下步骤对我有用

  1. 删除node_modules文件夹
  2. 删除yarn.lock如果您正在使用yarn命令或删除package-lock.json如果您正在使用npm命令
  3. 运行yarn install (对于 yarn 命令)或npm install (对于 npm 命令)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM