create-react-app - react-scripts:找不到命令

Emi*_*man 4 npm reactjs

我刚刚开始对 codepen 做出反应,我真的很喜欢它!我决定将它安装在我的 MacBook Air 上。我使用 npm 安装了 create-react-app,一切看起来都不错。然后我开始了一个项目,一切都很顺利。当我运行时npm 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! react-app@0.1.0 start: 'react-scripts start'
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the react-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)

我得出的结论是 npm 找不到 react-scripts。我已经完成了几乎所有我想出的事情:我已经更新了 npm;我已经重新安装了模块;我已经开始了一个新项目,但我仍然遇到同样的错误。我检查过,react-scripts 在我的 node_modules 文件中。我唯一没有做的是全局安装 react-scripts,但是 create-react-app 的创建者说这是一个非常糟糕的主意。我该怎么办?

Emi*_*man 5

刚刚解决了这个问题:

package.json,我改变了"start": react-scripts start",到"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"。这解决了问题。