- nodemon -v: 1.18.6
- node -v: v11.2.0
- Command: nodemon --exec babel-node lib/server.js
My app starts ok with the above command. When I change the source code, I expect the nodemon restart automatically. But I got the error Error: listen EADDRINUSE: address already in use :::3000
.
Error details
[nodemon] starting `babel-node lib/server.js`
events.js:167
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1294:14)
at listenInCluster (net.js:1342:12)
at Server.listen (net.js:1429:7)
at Function.listen (/Users/longntran/Desktop/learning/pangara-web/node_modules/express/lib/application.js:618:24)
at Object.listen (/Users/longntran/Desktop/learning/pangara-web/lib/server.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Module._compile (/Users/longntran/Desktop/learning/pangara-web/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Object.newLoader [as .js] (/Users/longntran/Desktop/learning/pangara-web/node_modules/pirates/lib/index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
Emitted 'error' event at:
at emitErrorNT (net.js:1321:8)
at internalTickCallback (internal/process/next_tick.js:72:19)
at process._tickCallback (internal/process/next_tick.js:47:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:778:11)
at Object.<anonymous> (/Users/longntran/Desktop/learning/pangara-web/node_modules/@babel/node/lib/_babel-node.js:224:23)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
Dependencies
"dependencies": {
"ejs": "^2.6.1",
"express": "^4.16.4",
"react": "^16.6.3",
"react-dom": "^16.6.3"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"@babel/node": "^7.0.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"jest": "^23.6.0",
"nodemon": "^1.18.6",
"pm2": "^3.2.2",
"prettier": "1.15.2",
"regenerator-runtime": "^0.13.1",
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2"
}
Note
I am using nodemon with babel 7. Please help me. Thank you guys
I found an interesting fix in this thread around adding a delay and kill process commands to your scripts.
And to add a delay to the nodemon command:
https://github.com/remy/nodemon/issues/1316#issuecomment-387367160
I also noticed that if I hit save twice in my code editor in rapid succession, I get this error. However if I only hit save once, I see no problem.