繁体   English   中英

反应启动脚本失败

[英]fail at react start script

我在 Intellij IDE 中处理 React 项目。 但是当我尝试使用 npm start 启动它时,我的项目失败了。 错误代码告诉我关键点是package.json 中启动脚本的开始。

我已经在这里尝试了最常见的建议:重新安装 node.js、node_modules。 但这对我不起作用。

谢谢你已经看到我的问题。

这是终端中的错误代码。

VXN5155:dhbw-engineering ThomasA$ npm start

> dhbw-engineering@0.1.0 start /Users/ThomasA/Desktop/Uni/3semester/Sw-:Webengineering/ProjektPraxisSwEngineering/dhbw-engineering
> react-scripts 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! dhbw-engineering@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the dhbw-engineering@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/ThomasA/.npm/_logs/2020-09-17T08_03_23_911Z-debug.log

编辑:以下是我的package.jsonscripts部分中定义的scripts

"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"
},

运行chmod +x node_modules/.bin/react-scripts

然后运行npm start 它应该工作

create-react-app之后,我在反应项目中的npm start遇到了同样的问题。

我通过以下方式修复它:

  • 在我的 react 应用程序根目录中创建.env文件。
  • 然后将SKIP_PREFLIGHT_CHECK=true添加到.env文件中。 这解决了问题。

然后npm startyarn start它应该可以工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM