我克隆了一个react应用程序到我的系统上,并运行以下命令

npm install -g create-react-app
npm install --save react react-dom

之后我就跑了

npm start 

但是它抛出了上面提到的错误,它在我的其他系统上工作得很好,我把它推到了github上。但克隆后,无论是windows还是mac,它都不能在任何其他系统上工作。


当前回答

在包中。json,我改变了

"start": "react-scripts start"

to

"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"

我希望这能解决一些人的问题。虽然上面的其他解决方案似乎不适合我。

其他回答

这个变通办法对我很管用

// in your package.json replace 
"start": "react-scripts start"

// with:
"start": "node_modules/react-scripts/bin/react-scripts.js start"

我在yarn 1.15.1-1的最新版本中遇到了问题

我已经通过降级到低版本sudo apt-get install yarn=1.12.3-1来修复它

当你用npm Install而不是yarn Install安装包时,这个错误会发生,反之亦然。

删除package-lock。Json和node_modules,然后NPM安装为我工作。

这让我一次又一次地感到困惑,当我有一个新的开始创建-反应-应用程序时,请确保你的NODE_ENV变量被设置为开发而不是生产,因为你的包中的devDependencies。NPM install不会安装Json。