尝试创建React App时出现Enoent错误

时间:2019-09-25 02:39:56

标签: npm create-react-app enoent

我正在尝试创建react-app,但是遇到一个ENOENT问题,这是命令提示符显示的内容:

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

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

Error: spawn C:\Windows\system32\cmd.exe; 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:80:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\Pedro Fernando\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:34:29)
    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:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn C:\\Windows\\system32\\cmd.exe;',
  path: 'C:\\Windows\\system32\\cmd.exe;',
  spawnargs: [
    '/d',
    '/s',
    '/c',
    '"npm ^"install^" ^"--save^" ^"--save-exact^" ^"--loglevel^" ^"error^" ^"react^" ^"react-dom^" ^"react-scripts@0.9.x^""'
  ]
}

有人有这个问题并且能够解决吗?

在任何人问: 这些是我的系统变量路径

Windows System Variables Path

3 个答案:

答案 0 :(得分:0)

请在您的终端中尝试以下操作:

First remove all node_modules: rm -fr node_modules/

followed by:

npm install npm@latest -g

npm install -g create-react-app

npm init react-app my-app

答案 1 :(得分:0)

尝试将react-scripts版本更改为2.1.8。这对我有用。

答案 2 :(得分:-1)

我已经遇到过几次这个问题。通常可以通过重新启动计算机来解决。