我克隆了一个react应用程序到我的系统上,并运行以下命令
npm install -g create-react-app
npm install --save react react-dom
之后我就跑了
npm start
但是它抛出了上面提到的错误,它在我的其他系统上工作得很好,我把它推到了github上。但克隆后,无论是windows还是mac,它都不能在任何其他系统上工作。
我克隆了一个react应用程序到我的系统上,并运行以下命令
npm install -g create-react-app
npm install --save react react-dom
之后我就跑了
npm start
但是它抛出了上面提到的错误,它在我的其他系统上工作得很好,我把它推到了github上。但克隆后,无论是windows还是mac,它都不能在任何其他系统上工作。
当前回答
在发出一个react-scripts构建请求后,我只是随机地遇到了这个“react-scripts: command not found”错误,这在以前工作得很好。
简单地重新启动系统就纠正了这个问题。
其他回答
安装Yarn就解决了我的问题
这个变通办法对我很管用
// in your package.json replace
"start": "react-scripts start"
// with:
"start": "node_modules/react-scripts/bin/react-scripts.js start"
使用NPM I -legacy-peer-deps对我有用。
我不知道它具体执行了以下哪个操作:
安装对等依赖项的最新稳定版本。 安装您正在安装的核心依赖所使用的对等依赖的版本。
但我认为它执行的是后一种操作。如果我错了,请随时告诉我^-^
这对我很管用。
如果你用的是纱线:
删除yarn.lock 运行纱 然后纱线开始
如果你正在使用npm:
删除package-lock.json 运行NPM install 然后NPM开始
在包中。json,我改变了
"start": "react-scripts start"
to
"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"
我希望这能解决一些人的问题。虽然上面的其他解决方案似乎不适合我。