简体   繁体   English

Create-react-app 没有创建应用程序并抛出错误

[英]Create-react-app is not creating app and throwing error

I have just started learning react but this error is coming in my way.我刚刚开始学习反应,但这个错误正在发生。 I have installed node.js latest version 14.6.0 and it has installed successfully.我已经安装了 node.js 最新版本14.6.0并且安装成功。 The npm is also installed with version 6.14.6 But Every time I use npm on command prompt it shows like this. npm 也安装了版本6.14.6但每次我在命令提示符下使用 npm 时,它都会显示如下。

'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
    operable program or batch file.

But that's not the problem, it stills work somehow I don't know.但这不是问题,它仍然以我不知道的方式工作。 By this I have installed create-react-app .通过这个我已经安装了create-react-app I have installed it by every single old or latest method(on their github) and it installs too and version is 3.4.1 .我已经通过每种旧的或最新的方法(在他们的 github 上)安装了它,它也安装了,版本是3.4.1 Now problem starts from here and I have tried every method for it to resolve.现在问题从这里开始,我已经尝试了所有方法来解决它。 I have changed PATH (which I didn't need to because paths were perfect).我已经改变了 PATH (我不需要因为路径是完美的)。 Error it throws is:它抛出的错误是:

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

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

Error: spawn C:\Windows\system32\cmd.exe; ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\HUZAIFA\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:274:12)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  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^""'
  ]
}

It creates the file with package.json in it only.它仅在其中创建包含 package.json 的文件。 Now I have been hitting my head for almost 4 or 5 hours but it isn't working.现在我已经敲了将近 4 或 5 个小时的头,但它不起作用。 npm.cmd in the nodejs folder does not open. npm.cmd文件夹中的npm.cmd打不开。 And There are many other issues with it or they are issues or not.它还有许多其他问题,或者它们是否存在问题。 I don't know yet but kindly help me with this.我还不知道,但请帮我解决这个问题。 Thanks.谢谢。

Try adding "%SystemRoot%\system32" to path variable in environment variables尝试将“%SystemRoot%\system32”添加到环境变量中的路径变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM