3
votes

While starting the server for the first time just after the code checkout , my react js project is throwing error "events.js:187 throw er; // Unhandled 'error' event" . I have node 12.13.0 and npm 6.12.0 . Log file attached log file

events.js:187
      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:80:21)
    Emitted 'error' event on ChildProcess instance 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:80:21) {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'spawn cmd',
    path: 'cmd',
    spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
15
ENOENT - Error NO ENTry - No such file or directoryJax-p
No log file available?HMR
Here is the log file . i.stack.imgur.com/B02xH.pngPriyam
downgrade the version of react-script from 3.0.1 to 2.1.8 and try npm install @PriyamAyushi Keshri
@AyushiKeshri Downgrading the version to 2.1.8 worked for me. Thank you so much for your help :)Priyam

15 Answers

4
votes

If your system is windows, set your environment variable, add %SystemRoot%\system32 to your PATH I met this error yesterday,hope it works to you. Don't forget reboot you PC

2
votes

Try this if none of the above answers solved u.. Go to My Computer>Properties>Advanced and in the environment variables Edit the PATH and add the following

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; C:\Program Files\nodejs;C:\Users{yourName}\AppData\Roaming\npm

Add 4 of them and restart your PC

2
votes

Downgrading the react-script version from 3.0.1 to 2.1.8 worked for me. Follow the following commands in sequence:- npm install [email protected] npm install npm start

1
votes

You can use node Your_File_Name.js command to run from the localhost. To use npm start command, you need to use scripts array in your package.json file "scripts": { "start": "http://localhost:3000/" } If this is not helpful can you attach more details?

1
votes

Try to execute export PATH=$PATH:/mnt/c/Windows/System32. Change the path /mnt/c/ to the path mounted on your wsl Windows (mount).

if it works, insert the path /mnt/c/Windows/System32 into the file /etc/environment.

here in my case this solution worked

1
votes

I faces this issue while using the windows subsystem for Linux and solved it by adding C:\Windows\System32 to Environment Variables Path. Environment Variables can add as follow.

go to

control panel -> System and Security ->System -> Advanced System Settings.

From the appearing dialog box, select Environment Variables, and then under System Variables select the path and select edit and add C:\Windows\System32. Restart the machine.

1
votes

Just in case this helps someone else, I started using [email protected] from a version of create-react-app that didn't include it, and suddenly I got this error.

It turned out the hot reload websocket was attempting to make a connection from the browser to my dev server, but it failed and crashed the app.

I found the fix here: I added transportMode: "ws" to my webpackDevServer.config.js beneath hot: true, and it worked.

0
votes

Make sure all the global & local packages that are being used in the scripts are installed, I've spent hours debugging an issue while deploying an application because webpack-cli & yarn wasn't installed globally & my project was trying to access it locally.

0
votes

In your package.json file try lowering the version of "react-scripts" to "2.1.8":

"dependencies": { 
    "@testing-library/jest-dom": "^4.2.4",  
    "@testing-library/react": "^9.4.0",  
    "@testing-library/user-event": "^7.2.1",  
    "react": "^16.12.0",  
    "react-dom": "^16.12.0",  
    "react-scripts": "2.1.8"  
  },  

Above works for me.

0
votes

If you are experiencing this error on ubuntu simply prepend "sudo" to the npm start command. That is sudo npm start

0
votes

downgrading react-scripts to npm install [email protected] works for me

0
votes

in my case react-scripts was missing from the devDependencies adding it in devDependencies resolved it for me. Hope this helps

0
votes

If downgrading react-scripts not working for you please follow below steps

  1. Search Edit the system environment variable and open it.
  2. Click on Environment Variables.
  3. Select Path in system variables section and click on Edit.
  4. Click on New and add this %SystemRoot%\system32
  5. Click on OK everywhere and restart the system.
0
votes

Try adding the following environment variables to PATH. (System variables)

C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem

They should be there by default but mine were missing for someone reason. I added them and the problem disappeared.

0
votes

Had the same problem in windows, deleting the node_modules and then a npm install fixed it for me.