我目前正在尝试使用create-react-app,它使用了三个不同的包: react,react-scripts和react-dom。我已经安装了create-react-app,然后当我切换到目录并点击npm start时,我得到了一个react-scripts: command not found。我在这方面遇到了很多问题。我可以看到react-scripts在我的node_modules文件夹中,但当我尝试运行npm start时,我总是得到command not found。我试图删除并重新安装我所有的node_modules,但它不起作用。还有谁有这个问题吗?
✘ ✝ Node/toDoApp/my-test master± npm start
> my-test@0.1.0 start /Users/jzilch/Desktop/Web
Projects/Node:Express/Node/toDoApp/my-test
> react-scripts start
sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-test@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-test@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.发布于 2018-01-03 00:59:31
首先删除项目文件夹中的package-lock.json文件。
然后通过npm install再次安装依赖项。这应该可以解决这个问题。
发布于 2018-03-08 19:06:04
这通常是因为npm包安装不好而导致的(同时使用npm和yarn?)。这可能会让人绝望,但如果你尝试这些步骤,它应该会起作用。
的第一个解决方案:
删除node_modules文件夹。在项目的根文件夹中,运行
> yarn
> yarn run start第二个解决方案:
在项目的根文件夹中,运行
> yarn upgrade
> yarn
> yarn run start下次你想使用create-react-app添加依赖项时,我建议你使用'yarn add‘而不是'npm install’。(来源:https://github.com/facebook/create-react-app/issues/1155)
发布于 2019-02-04 01:17:08
使用rm命令删除/node_modules目录和package-lock.json文件:
rm -rf node_modules
rm -rf package-lock.json使用以下命令安装react-scripts:
npm install react-scripts使用以下命令安装依赖项:
npm install通过运行以下命令启动本地服务器:
npm run start注意:如果您是Linux用户,那么不要忘记在npm之前添加sudo命令。
https://stackoverflow.com/questions/47612580
复制相似问题