Nikhil
Nikhil

Reputation: 374

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??

Upvotes: 8

Views: 16825

Answers (6)

adil rehman
adil rehman

Reputation: 1

This issue is occurs because nodemon is not installed properly please follow the instructions:

  • check your nodemon by using command nodemon -v.

version:
2.0.22

  • If you received nodemon version then it's working well otherwise use npm install nodemon -g command to install package.

  • use lsof -i -n -P | grep node command to check your node.js running PORTS such as:

output:
node 460517 adil 20u IPv6 13299837 0t0 TCP *:3003 (LISTEN)

  • if you received then kill unusable running PORTS by using kill -9 460517 command.

  • Run nodemon ./index.ts or npm start command.

Issue resolved.

Upvotes: 0

Md. Rumon Khan
Md. Rumon Khan

Reputation: 187

In my case,

Error: [nodemon] Internal watch failed: EMFILE: too many open files, watch

Solution:

  1. I close the vs code,
  2. Reopen it, and solve the problem.

Upvotes: 6

Rahul Joshi
Rahul Joshi

Reputation: 1

I've also faced this issue and I have tried all the solutions mentioned above but the solution works for me is just close the IDE and restart again the IDE it will help me.

Upvotes: 0

Rob
Rob

Reputation: 275

I had this same error. Node worked, but not nodemon. All I did was:

npm install -g nodemon

And it worked 😃

Upvotes: 1

Ganesh Apune
Ganesh Apune

Reputation: 197

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

Upvotes: 2

ronme
ronme

Reputation: 1172

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.

Upvotes: 11

Related Questions