简体   繁体   English

使用 cmd 在 React Js 应用程序中启动时出现 npm start 错误

[英]npm start error on Starting in React Js App using cmd

I have created a Simple React App but when i am going to run it using cmd "npm start" it throws a bunch of errors.我创建了一个简单的 React 应用程序,但是当我要使用 cmd "npm start" 运行它时,它会引发一堆错误。 I also reinstall node js on my system and install many times node_modules.我还在我的系统上重新安装了 node js 并安装了很多次 node_modules。 but everything gonna failed.但一切都会失败。 I have also tried to run other projects on my system but I am getting almost same type of error.我还尝试在我的系统上运行其他项目,但我遇到了几乎相同类型的错误。

C:\Users\Administrator\Desktop\reactApp>npm start

> testapp@1.0.0 start C:\Users\Administrator\Desktop\reactApp
> webpack-dev-server --mode development --open --hot

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.8.0
3 info using node@v11.10.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle testapp@1.0.0~prestart: testapp@1.0.0
6 info lifecycle testapp@1.0.0~start: testapp@1.0.0
7 verbose lifecycle testapp@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle testapp@1.0.0~start: PATH: C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Administrator\Desktop\reactApp\node_modules\.bin;C:\Users\Administrator\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Program Files\Microsoft MPI\Bin\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.2 & MySQL Utilities 1.5.2 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.2 & MySQL Utilities 1.5.2 1.5\Doctrine extensions for PHP\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm
9 verbose lifecycle testapp@1.0.0~start: CWD: C:\Users\Administrator\Desktop\reactApp
10 silly lifecycle testapp@1.0.0~start: Args: [ '-c', 'webpack-dev-server --mode development --open --hot' ]
11 info lifecycle testapp@1.0.0~start: Failed to exec start script
12 silly lifecycle testapp@1.0.0~start: Returned: code: -4058  signal: null
13 info lifecycle testapp@1.0.0~start: Failed to exec start script
14 verbose stack Error: testapp@1.0.0 start: `webpack-dev-server --mode development --open --hot`
14 verbose stack spawn bash ENOENT
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
14 verbose stack     at onErrorNT (internal/child_process.js:427:16)
14 verbose stack     at processTicksAndRejections (internal/process/next_tick.js:76:17)
15 verbose pkgid testapp@1.0.0
16 verbose cwd C:\Users\Administrator\Desktop\reactApp
17 verbose Windows_NT 10.0.17134
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 verbose node v11.10.1
20 verbose npm  v6.8.0
21 error file bash
22 error path bash
23 error code ELIFECYCLE
24 error errno ENOENT
25 error syscall spawn bash
26 error testapp@1.0.0 start: `webpack-dev-server --mode development --open --hot`
26 error spawn bash ENOENT
27 error Failed at the testapp@1.0.0 start script.
27 error This is probably not a problem with npm. There is likely additional logging output above.
28 verbose exit [ 1, true ]


npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-03-06T12_08_45_188Z-debug.log

C:\Users\Administrator\Desktop\reactApp>

I think you forgot to either run npm install in your project directory or forgot to install webpack-dev-server before running npm start .我认为您忘记在项目目录中运行npm install或在运行npm start之前忘记安装webpack-dev-server

This issue on GitHub has pretty much the exact same error with the same solution: https://github.com/vuejs/vue-cli/issues/486 GitHub 上的这个问题与相同的解决方案几乎完全相同https : //github.com/vuejs/vue-cli/issues/486

I think the best solution to this problem is to go to the following path first and apply these changes, and then restart your system and try again.我认为解决此问题的最佳方法是先转到以下路径并应用这些更改,然后重新启动系统并重试。

Control Panel>System and Security>System>Advance system setting>Enviroment variable and set system variables path C:\\Windows\\System32\\ variable and restart your System.控制面板>系统和安全>系统>高级系统设置>环境变量并设置系统变量路径C:\\Windows\\System32\\变量并重新启动系统。

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

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