Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodemon internal watch failed error?

I don't know what happened but suddenly my Nodemon starting to show the error.

nikhil@nikhil-Lenovo-Z50-70:~/Desktop/dominos$ nodemon server.js
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
[nodemon] Internal watch failed: watch /home/nikhil/Desktop/dominos 
ENOSPC

Even though after that my program runs fine. But when I close this project1 and runs another project2 on the same port then this error occurs

Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at Server.setupListenHandle [as _listen2] (net.js:1319:14)
at listenInCluster (net.js:1367:12)
at Server.listen (net.js:1467:7)
at Object.<anonymous> (/home/nikhil/Desktop/dominos/server.js:533:8)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3

And then my old project1 would remain open and my new project2 cannot be started until I manually kill the process.

Any idea why this is happening??

like image 560
Nikhil Avatar asked Oct 25 '17 16:10

Nikhil


2 Answers

Assuming you're on linux, the issue could be that you have too many open watchers. Run this command:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

and try again.

Credit: this answer.

like image 141
ronme Avatar answered Oct 20 '22 11:10

ronme


This issue is occurring because already another process or terminal use your same port

kill all node by using following command

killall node

start nodemon by using following comand

nodemon server.js
like image 2
Ganesh Apune Avatar answered Oct 20 '22 11:10

Ganesh Apune