Node.js – events js 72 throw er unhandled 'error' event

后端 未结 6 1566
攒了一身酷
攒了一身酷 2020-12-04 14:19

I\'m new to Node.js and wish to run a program using streams. With other programs, I had to start a server simultaneously (mongodb, redis, etc) but I have no idea if I\'m sup

相关标签:
6条回答
  • 2020-12-04 14:43

    Check your terminal it happen only when you have your application running on another terminal..

    The port is already listening..

    0 讨论(0)
  • 2020-12-04 14:44

    I had the same problem. I closed terminal and restarted node. This worked for me.

    0 讨论(0)
  • 2020-12-04 14:47

    Close nodejs app running in another shell. Restart the terminal and run the program again.


    Another server might be also using the same port that you have used for nodejs. Kill the process that is using nodejs port and run the app.

    To find the PID of the application that is using port:8000

    $ fuser 8000/tcp
    8000/tcp:            16708
    

    Here PID is 16708 Now kill the process using the kill [PID] command

    $ kill 16708
    
    0 讨论(0)
  • 2020-12-04 14:52

    For what is worth, I got this error doing a clean install of nodejs and npm packages of my current linux-distribution I've installed meteor using

    npm install metor
    

    And got the above referenced error. After wasting some time, I found out I should have used meteor's way to update itself:

    meteor update
    

    This command output, among others, the message that meteor was severely outdated (over 2 years) and that it was going to install itself using:

    curl https://install.meteor.com/ | sh
    

    Which was probably the command I should have run in the first place.

    So the solution might be to upgrade/update whatever nodejs package(js) you're using.

    0 讨论(0)
  • 2020-12-04 14:53

    Well, your script throws an error and you just need to catch it (and/or prevent it from happening). I had the same error, for me it was an already used port (EADDRINUSE).

    0 讨论(0)
  • 2020-12-04 14:58

    I always do the following whenever I get such error:

    // remove node_modules/
    rm -rf node_modules/
    // install node_modules/ again
    npm install // or, yarn
    

    and then start the project

    npm start //or, yarn start
    

    It works fine after re-installing node_modules. But I don't know if it's good practice.

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