ExpressJS - throw er Unhandled error event

前端 未结 30 1907
囚心锁ツ
囚心锁ツ 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:22

    I ran into the same issue today and the port was not used. The following approach helped:

    rm -rf node_modules && npm cache clean && npm install
    npm start
    
    0 讨论(0)
  • 2020-12-12 10:22

    ->check what’s running on port 8080 or what ever port u want to check

    lsof -i @localhost:8080
    

    if something is running u can close it or use some kill command to close it

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

    This worked for me.

    http://www.codingdefined.com/2015/09/how-to-solve-nodejs-error-listen.html

    Just change the port number from the Project properties.

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

    After killing the same process multiple times and not being able to locate what else was running on port 8000, I realized I was trying to run on port 8000 twice:

    Before:

    MongoClient.connect(db.url, (err, database) => {
      if (err) return console.log(err);
      require('./app/routes')(app, database);
    
      app.listen(port, () => {
        console.log('We are live on ' + port);
      });
    });
    
    require('./app/routes')(app, {});
    app.listen(port, () => {
      console.log("We are live on " + port);
    });
    

    After:

    MongoClient.connect(db.url, (err, database) => {
      if (err) return console.log(err);
      require('./app/routes')(app, database);
    
      app.listen(port, () => {
        console.log('We are live on ' + port);
      });
    });
    
    require('./app/routes')(app, {});
    
    0 讨论(0)
  • 2020-12-12 10:28

    Close any other node servers that are running, even if they are in other terminal windows or running on different ports. That should fix the problem.

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

    events.js:183 throw er; // Unhandled 'error' event

    I also got the same kind of problem and tried many ways but finally got this, this works well:

    npm install ws@3.3.2 --save-dev --save-exact
    

    Refer to this link for more clarifications https://github.com/ionic-team/ionic-cli/issues/2922

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