我正在尝试下载React js,但是又一次又一次出现此错误?

时间:2019-08-28 21:48:24

标签: javascript html reactjs

我正在使用npm下载react js,但是一次又一次出现此错误。任何人都可以给我解决方案。我已经尝试了多次,但仍然给我同样的错误。

C:\ react \ todo> npm start

> todo@0.1.0 start C:\react\todo
> react-scripts start
Starting the development server...

events.js:180
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo@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\HAROON & ABDULREHMAN\AppData\Roaming\npm-cache\_logs\2019-08-28T21_27_54_711Z-debug.log

2 个答案:

答案 0 :(得分:0)

经过研究,我发现了这一点。

I(tylerlaberge)也遇到了这个确切的问题,发现它只在react-scripts@3.0.0中存在,降级到react-scripts@2.1.8解决了该问题,而无需弄乱环境变量。

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start

https://github.com/facebook/create-react-app/issues/6985#issuecomment-490319841

答案 1 :(得分:0)

您应该使用npx create-react-app appname,它来自react docs https://reactjs.org/docs/create-a-new-react-app.html。当我使用npm create-react-app时,我经常遇到很多问题,当我说使用npx时,它们都消失了。