nodemon: An error "Error: watch ENOSPC"

20 Oct 16:40:37 - [nodemon] v0.7.10
20 Oct 16:40:37 - [nodemon] to restart at any time, enter `rs`
20 Oct 16:40:37 - [nodemon] watching: /my/proyect/server
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/usr/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/lib/node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
20 Oct 16:40:37 - [nodemon] reading ignore list
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at fs.watch (fs.js:1076:11)
    at checkTimer (/usr/lib/node_modules/nodemon/nodemon.js:467:27)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 56 (19 by maintainers)

Most upvoted comments

The system has a limit to how many files can be watched by a user. You can run out of watches pretty quickly if you have Grunt running with other programs like Dropbox.

The post suggest running this to increase the number of watches that are available.

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

This might be because of your system reach out of user can watch files. you can use the following command line in ubuntu echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p or try npm dedupe

Ref to this stackoverflow

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

The fs notify trick doesn’t seem to work on a docker container… at least not Alpine 3.8, I get the same ENOSPC error. It’s becoming more important as tools get deprecated and we still need to maintain legacy products

As soon as I open a directory with many files in Sublime 2 nodemon doesn’t work anymore and spits out the referenced error. I was only able to work around that by not using Sublimes “open folder” feature. Thank you for the hint @eyce9000.

@ankibalyan @uttampanara

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

@taylorjbrennan yeah, I know that will fix the issue, but whilst @chok is able to replicate consistently, I’m after a change that will fix nodemon without the user needing to do the max_user_watches io magic.

Another possible solution is to add a nodemon.json configuration file in your root folder and specify ignore patterns for example: nodemon.json

{
  "ignore": [
    "*.test.js", 
    "dist/*"
  ]
}
  • Note that by default .git, node_modules, bower_components, .nyc_output, coverage and .sass-cache are ignored so you don’t need to add them to your configuration.

Run this command

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

Not many, 30 at max. But i think nodemon is trying to watch node_modules at the root of the project. Below is the config passed to nodemon (I’m using it as a node module):

nodemon({
    script: 'server/server.js',
    watch: [
        'server/',
        'common/'
    ],
    ext: 'js json coffee'
});

the server folder has: 7 coffee files 5 json files and the common folder has just 1 json file…