我知道已经有人问过这个问题,但我找不到解决方案。当我npm start
在 React 项目中运行时,我总是得到相同的日志(见下文)。给出的唯一解决方案是卸载node_modules
并重新安装。我也尝试清除缓存。没有任何效果。
有些人解决了升级到react-scripts 3.4.0
(https://github.com/facebook/create-react-app/issues/8490)的这个问题,但这对我不起作用。唯一的解决办法我现在已经是降级react-scripts
到的版本2.1.8
使用npm install react-scripts@2.1.8
。但这不是一个好的解决方案,因为我必须在使用最新版本的框架上工作。
这是日志:
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