反应脚本 3.4.0 的 npm start 问题 [英] npm start issues with react-scripts 3.4.0
问题描述
我知道已经有人问过这个问题,但我找不到解决方案.当我在 React 项目中运行 npm start
时,我总是得到相同的日志(见下文).给出的唯一解决方案是卸载 node_modules
并重新安装.我也尝试清除缓存.没有任何效果.
I know this question has already been asked but I can't find a solution. When I run npm start
inside a react project, I always get the same logs (see below). The only solution given is to uninstall node_modules
and re-do the installation. I also tried to clear the cache. Nothing worked.
有些人升级到 react-scripts 3.4.0
(https://github.com/facebook/create-react-app/issues/8490) 但这对我不起作用.我现在唯一的解决方案是使用 npm install react-scripts@2.1.8
将 react-scripts
降级到 2.1.8
版本.但这不是一个好的解决方案,因为我必须在使用最新版本的框架上工作.
Some people solved this problem upgrading to react-scripts 3.4.0
(https://github.com/facebook/create-react-app/issues/8490) but that didn't work for me. The only solution I have now is to downgrade react-scripts
to version 2.1.8
by using npm install react-scripts@2.1.8
. But it's not a good solution because I have to work on a framework that uses the latest version.
这里是日志:
i 「wds」: Project is running at http://192.168.43.27/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\fthom\Desktop\temp\my-app\public
i 「wds」: 404s will fallback to /index.html
Starting the development server...
events.js:288
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@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\fthom\AppData\Roaming\npm-cache\_logs\2020-02-21T10_59_13_574Z-debug.log
推荐答案
我终于找到了解决方案.在机器PATH中添加默认变量:
I finally found a solution. Add the default variables in the machines PATH:
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
这篇关于反应脚本 3.4.0 的 npm start 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!