首页 > 解决方案 > 当尝试运行 react-bootstrap 或一般只做出反应时,我总是得到 events.js:287 和其他错误,如下所示

问题描述

events.js:287
      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\JoseH\AppData\Roaming\npm-cache\_logs\2020-05-08T20_10_31_948Z-debug.log
The terminal process terminated with exit code: 1

这总是会出现的,我不知道该怎么做才能解决这个问题,我对使用反应相当陌生,我想知道我能做些什么来解决这个问题。我尝试使用 npm 清除缓存,但没有奏效。我不确定如何更改正在使用的端口,但如果有人可以帮助我,我觉得这可能会奏效。

标签: reactjs

解决方案


检查您的 package.json 以获取值为 react-scripts start 的启动键

"scripts": {
    "start": "react-scripts start", //as its here
    "build": "react-scripts build",
    "test": "jest --coverage --coverageDirectory=output/coverage/jest",
    "eject": "react-scripts eject"
  },

如果它不存在,则将其更改为如上所示

如果它仍然不起作用,请运行

npm install

如果它仍然存在..尝试使用此清理缓存

npm cache clean --force

希望这可以帮助!


推荐阅读