Why npm start is throwing events.js:187 throw er; // Unhandled 'error' event in my react project?

ⅰ亾dé卋堺 提交于 2019-12-21 03:00:59

问题


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/' ]
}

回答1:


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:


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?




回答3:


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




回答4:


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.




回答5:


Downgrading the react-script version from 3.0.1 to 2.1.8 worked for me. npm install react-scripts@2.1.8 npm install npm start



来源:https://stackoverflow.com/questions/58603936/why-npm-start-is-throwing-events-js187-throw-er-unhandled-error-event-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!