ExpressJS - throw er Unhandled error event

前端 未结 30 1906
囚心锁ツ
囚心锁ツ 2020-12-12 09:30

I created expressjs application using the following commands:

express -e folderName
npm install ejs --save
npm install

When I run the appli

相关标签:
30条回答
  • 2020-12-12 10:08

    In my case I've had to run vagrant reload as well. Even with no node processes running my express app in my virtual machine I was still getting this error until reloading the vagrant box.

    0 讨论(0)
  • 2020-12-12 10:09

    We do get similar error when we sometimes run our express app. We have to follow the same in that case. We need to check if its running in any terminal. If you want to find and kill process, follow these steps:

    • ps aux | grep node
    • Find the process ID (second from the left):
    • kill -9 PRCOCESS_ID

    OR

    Use a single command to close all the running node processes.

    ps aux | awk '/node/{print $2}' | xargs kill -9
    
    0 讨论(0)
  • 2020-12-12 10:09

    The port Node is trying to use can be already used by another program. In my case it was ntop, which I had recently installed. I had to open http://localhost:3000/ in a browser to realize it. Another way to find the process is given here.

    0 讨论(0)
  • 2020-12-12 10:09

    In-order to fix this, terminate or close the server you are running. If you are using Eclipse IDE, then follow this,

    Run > Debug

    enter image description here

    Right-click the running process and click on Terminate.

    0 讨论(0)
  • 2020-12-12 10:10

    Actually Ctrl+C keys not releasing port used by node process. So there is this error. The resolution to the issue was using following code snippet in server.js:

    process.on('SIGINT', function() {
      console.log( "\nGracefully shutting down from SIGINT (Ctrl-C)" );
      // some other closing procedures go here
      process.exit(1);
    });
    

    This worked for me.

    You can also check for other solutions mentioned at Graceful shutdown in NodeJS

    0 讨论(0)
  • 2020-12-12 10:10

    My answers is one of the solution

    If you are trying to run angular application with below command

    ng serve --open
    

    --open Opens the url in default browser this tag is causing the issue. i don't know what is the purpose after angular 10 version which is not working. I am still analysing

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