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

后端 未结 11 921
抹茶落季
抹茶落季 2020-12-15 14:35

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\'

相关标签:
11条回答
  • 2020-12-15 14:53

    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 讨论(0)
  • 2020-12-15 15:02

    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?

    0 讨论(0)
  • 2020-12-15 15:02

    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

    0 讨论(0)
  • 2020-12-15 15:02

    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 讨论(0)
  • 2020-12-15 15:03

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

    0 讨论(0)
  • 2020-12-15 15:06

    Downgrading the react-script version from 3.0.1 to 2.1.8 worked for me. Follow the following commands in sequence:- npm install react-scripts@2.1.8 npm install npm start

    0 讨论(0)
提交回复
热议问题