简体   繁体   English

无法启动 React 项目

[英]Unable to launch React Project

Please find the error logs which I am getting in the terminal请找到我在终端中得到的错误日志

fruits-vegetables@0.1.0 start C:\Users\MY PC\My_Front_End\fruits-vegetables
> react-scripts start
Could not find a required file.
  Name: index.html
  Searched in: C:\Users\MY PC\My_Front_End\fruits-vegetables\public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fruits-vegetables@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fruits-vegetables@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!     C:\Users\MY PC\AppData\Roaming\npm-cache\_logs\2019-12-20T15_57_41_927Z-debug.log

Please find the debug error log请查找调试错误日志

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\MY PC\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle fruits-vegetables@0.1.0~prestart: fruits-vegetables@0.1.0
6 info lifecycle fruits-vegetables@0.1.0~start: fruits-vegetables@0.1.0
7 verbose lifecycle fruits-vegetables@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle fruits-vegetables@0.1.0~start: PATH: C:\Users\MY PC\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\MY PC\My_Front_End\fruits-vegetables\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\MY PC\AppData\Local\Microsoft\WindowsApps;C:\Users\MY PC\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\MY PC\AppData\Roaming\npm;C:\Program Files\Git\bin;C:\Program Files (x86)\Nmap
9 verbose lifecycle fruits-vegetables@0.1.0~start: CWD: C:\Users\MY PC\My_Front_End\fruits-vegetables
10 silly lifecycle fruits-vegetables@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle fruits-vegetables@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle fruits-vegetables@0.1.0~start: Failed to exec start script
13 verbose stack Error: fruits-vegetables@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\MY PC\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:209:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\MY PC\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:209:13)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid fruits-vegetables@0.1.0
15 verbose cwd C:\Users\MY PC\My_Front_End\fruits-vegetables
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MY PC\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.10.0
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error fruits-vegetables@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the fruits-vegetables@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Moreover, I have already tried these suggestions:此外,我已经尝试过这些建议:

  1. delete node modules and package-lock.json删除节点模块package-lock.json
  2. then ran command: npm update然后运行命令: npm update
  3. then ran command: npm install然后运行命令: npm install
  4. and when I ran npm start I got the same error as above当我运行npm start时,我遇到了与上面相同的错误

One more thing which I noticed, whenever I freshly install a react app then I used to get App.js, index.js, index.html even a src folder, I am not getting all these.我注意到的另一件事是,每当我新安装一个 React 应用程序时,我都会得到 App.js、index.js、index.html 甚至一个 src 文件夹,但我没有得到所有这些。 Please help!请帮忙!

我以前也遇到过这个问题,但幸运的是我永远修复了它,您可以通过转到 -> 控制面板 -> 系统和安全 -> 系统 -> 高级系统设置 -> 环境变量查找系统变量并查看对于 ComSpec 确保路径是这样的C:\\Windows\\system32\\cmd.exe并重新启动系统,看看它会工作

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

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