【发布时间】:2020-07-29 14:42:17
【问题描述】:
我已经学习 react 大约两个星期了,突然 npm start 无法运行。这就是我得到的:
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! recipe-app@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the recipe-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Michelle/.npm/_logs/2020-07-29T14_35_20_988Z-debug.log
经过大量的谷歌搜索后,我尝试了
npm install -g npm@latest 但权限被拒绝。
多次删除并重新安装节点,尝试使用 Homebrew 等,但没有任何效果。
编辑:找到解决方案!
npm 找不到 react-scripts,所以我不得不将package.json 中的脚本更改为
"start": "node_modules/react-scripts/bin/react-scripts.js start".
【问题讨论】:
-
运行命令时你确定你和你的 package.json 文件在同一个目录吗? - npm 在此查找命令
-
运行
npm时得到什么输出 -
@MikeW 在上面的帖子中添加了它
-
我看到您是 StackOverflow 社区的新手。我建议您了解可以在帮助中心找到的内容。特别是本节:stackoverflow.com/help/someone-answers 特别是为了避免在您自己的问题中编写解决方案。
-
别忘了将答案标记为最合适的答案 :)(即使是你的)