无法启动React项目

时间:2019-12-20 16:22:10

标签: node.js reactjs npx

请在终端中找到我得到的错误日志

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

请找到调试错误日志

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 ]

此外,我已经尝试了以下建议:

  1. 删除节点模块 package-lock.json
  2. 然后运行命令: npm更新
  3. 然后运行命令: npm install
  4. 当我运行 npm start 时,遇到了与上述相同的错误

我注意到的另一件事是,每当我刚安装一个React应用时,我就曾经获得过App.js,index.js,index.html甚至是src文件夹,但我却没有得到所有这些。请帮忙!

1 个答案:

答案 0 :(得分:0)

我之前也遇到过这个问题,但是幸运的是,我永久修复了它,您可以通过->控制面板->系统和安全性-> system->高级系统设置->环境变量查找系统来解决此问题。变量并查找ComSpec,以确保路径类似于C:\Windows\system32\cmd.exe,然后重新启动系统,看看它是否可以正常工作