我每次启动npm start
时都会收到此错误,因为我在同一个端口上运行了一个进程,所以我必须使用{{ 1}}并杀死进程。
但是在每次更改文件时执行此操作都非常不方便,我也遇到了错误,因为nodemon可能会导致错误:netstat -nlp | grep 3000
App.js:
[nodemon] app crashed - waiting for file changes before starting...
答案 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)