Error while creating app using command prompt

Viewed 333

I have installed nodejs and checked nodejs, npm and npx versions. All seems great and executed npm install -g create-react-app and it also got executed correctly. But after writing create-react-app myapp it is showing this error on command prompt.

Creating a new React app in `C:\Users\Dell\Documents\Javascript Tutorial && Summer training\reactjs course\todolist`

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

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

Error: spawn C:\Windows\system32\cmd.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\Dell\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:275:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82: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^""'
  ]
}

enter image description here

1 Answers

This is not the correct way to initialize a react Application, as it's the incorrect use of npx.

Try uninstalling globally create-react-app

$ npm uninstall -g create-react-app

and then initializing your app

$ npx create-react-app myapp
Related