1

我正在尝试创建 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 系统变量路径

4

3 回答 3

0

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

于 2020-05-14T08:58:54.003 回答
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
于 2019-09-25T04:52:41.490 回答
-1

这个问题我遇到过几次。一般重启电脑就可以解决。

于 2020-01-13T19:20:25.400 回答