2017-11-02 13 views
0

npm startを起動するたびにこのエラーが表示されますが、これは同じポートで実行されているプロセスによるものですから、netstat -nlp | grep 3000で検索してプロセスを終了する必要があります。 [nodemon] app crashed - waiting for file changes before starting...nodeJS - 未処理の「エラー」イベント

enter image description here

App.js:

しかし、それはすべてのファイルの変更でこれを行うには非常に不便だが、私もそれを引き起こす可能性がありnodemonとの誤差を持っている

var mongoose = require("mongoose"); 
var bodyParser = require("body-parser"); 
mongoose.Promise = require("bluebird"); 
var apiRouter = require('./routes/routes'); 
var express = require("express"); 
var app = express(); 

//raccourci pour bootstrap 
app.use(bodyParser.urlencoded({ 
    extended: true 
})); 
app.use(bodyParser.json()); 
app.use(express.static('public')); 
app.set('view engine', 'ejs'); 
//Ajout du slug course 
app.use('/courses', apiRouter); 

//Connexion à la bdd 
mongoose.connect('mongodb://my_connection_string') 
       .then(
        console.log("CONNECTE !!!") 
       ); 

app.listen(3000, function(){ 
    console.log("Bonjour !"); 
}); 
+0

あなたはあなたのコードを表示することができますか? (app.jsファイル) –

+0

@Héctorを完了しました –

答えて

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)

+0

ああ、この問題が何度も起こりました。指摘してくれてありがとう! –

関連する問題