It appears that my max ports weren't configured correctly. I ran the following code and it worked...
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
What this command does is to increase the number of watches allowed for a single user. By the default the number can be low (8192 for example). When nodemon
tries to watch large numbers of directories for changes it has to create several watches, which can surpass that limit.
You could also solve this problem by:
sudo sysctl fs.inotify.max_user_watches=582222 && sudo sysctl -p
But the way it was written first will make this change permanent.
nodemon server.js
[nodemon] 1.17.2
[nodemon] to restart at any time, enter
rs
[nodemon] watching: .
[nodemon] starting
node server.js
sudo pkill -f node
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Erik, You can just kill all the other node processes by
pkill -f node
and then restart your server again. It'll work just fine then.
As per discussion over here, ENOSPC
means Error No more hard-disk space available
. Reason why this much memory required by nodemon
or gulp-nodemon
(in my case) is that it was watching contents of a folder which it shouldn't. To fix that nodemon has ignore
setting that can be used to tell nodemon what not to watch. Have a look at nodemon sample config here.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
This worked for me
[nodemon] Internal watch failed: watch /home/Document/nmmExpressServer/bin ENOSPC
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `nodemon ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
This is the error I got when running nodemon ./bin/www
.
The solution was closing an Atom window that had a entire directory of folders open in the project window.
I don't know why, but I'm assuming Atom and nodemon use similar processes to watch files/folders.
Try this....
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With