nodeJS - 未处理的'错误'事件

时间:2017-11-02 17:06:03

标签: node.js npm nodemon

我每次启动npm start时都会收到此错误,因为我在同一个端口上运行了一个进程,所以我必须使用{{ 1}}并杀死进程。

但是在每次更改文件时执行此操作都非常不方便,我也遇到了错误,因为nodemon可能会导致错误:netstat -nlp | grep 3000

enter image description here

App.js:

[nodemon] app crashed - waiting for file changes before starting...

1 个答案:

答案 0 :(得分:3)

当您的应用崩溃时杀死猫鼬:

process.on("SIGINT", () => {
    mongoose.connection.close(() => {
        console.log("App is closing, ending mongoose connection");
        process.exit(0);
    });
});

虽然,您可能遇到了这个错误:

remy/nodemon #1025: Nodemon frequently leaves the child process running (detached)

相关问题