Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error "Error: watch ENOSPC" #214

Closed
jamlfy opened this issue Oct 20, 2013 · 56 comments
Closed

An error "Error: watch ENOSPC" #214

jamlfy opened this issue Oct 20, 2013 · 56 comments

Comments

@jamlfy
Copy link

jamlfy commented Oct 20, 2013

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)
@remy
Copy link
Owner

remy commented Oct 20, 2013

Version of Node?

@remy
Copy link
Owner

remy commented Oct 20, 2013

Also, can you provide a simple test case script you're using (to test with).

@jamlfy
Copy link
Author

jamlfy commented Oct 21, 2013

use Node 0.10.21. With any script, generates an error.

@remy
Copy link
Owner

remy commented Oct 27, 2013

Is this the same issue as #144? I can't replicate this on my mac (though I didn't ask what OS you had, but assumed *nix type based on the path in your paste above).

@jamlfy
Copy link
Author

jamlfy commented Oct 28, 2013

Not the same, are different here is running a single processo. In the other runs on multiple processo, non-cloud

@davidbarton
Copy link

Experienced this error today with multiple apps (express, restify).

NodeJS: v0.10.21
ElementaryOS Version: 0.2 "Luna" ( 64-bit )
Built on: Ubuntu 12.04 ( "Precise" )
Kernel 3.5.0-43-generic

11 Nov 17:32:38 - [nodemon] v0.7.10
11 Nov 17:32:38 - [nodemon] to restart at any time, enter `rs`
...
11 Nov 17:32:38 - [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 (/home/.../node_modules/nodemon/nodemon.js:160:6)
    at ready (/home/.../node_modules/nodemon/nodemon.js:49:22)
    at /home/.../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)

reproduce:

npm install nodemon
./node_modules/.bin/nodemon app.js

app.js (from http://nodejs.org/)

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

@davidbarton
Copy link

I got same error with CoffeeScript --watch ./node_modules/.bin/coffee --watch app/

/home/.../node_modules/coffee-script/lib/coffee-script/command.js:334
        throw e;
              ^
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 watchDir (/home/.../node_modules/coffee-script/lib/coffee-script/command.js:299:27)
    at /home/.../node_modules/coffee-script/lib/coffee-script/command.js:102:11
    at Object.oncomplete (fs.js:107:15)

@chok
Copy link

chok commented Nov 27, 2013

I got the same error with a compound.js project using coffeescript on Ubuntu 13.10 with node 0.10.21

$ nodemon server.coffee

27 Nov 21:40:14 - [nodemon] v0.7.10
27 Nov 21:40:14 - [nodemon] to restart at any time, enter `rs`
27 Nov 21:40:14 - [nodemon] watching: /home/chok/work/edf/bluetic/src
27 Nov 21:40:14 - [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/local/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/local/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/local/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)

@remy
Copy link
Owner

remy commented Dec 3, 2013

Can someone have a go at this with the dev version of nodemon? I've made a lot of changes and am trying to concentrate my efforts on making sure the new version gets all these issues closed.

You can install using npm install -g nodemon@dev

@davidbarton
Copy link

Works for me now dunno why. Using latest stable nodemon npm version. Also had same issue with coffeescript --watch and this works too now. No node update, just npm install modules and distro updates.

@chok
Copy link

chok commented Dec 3, 2013

I have the same error but the process stop :

$ nodemon server.coffee 
3 Dec 15:32:42 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] 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 Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36: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)

@remy
Copy link
Owner

remy commented Dec 3, 2013

@chok can you run the following (and paste the result) for me in the same directory you're running nodemon:

find . | wc

I'm trying to get an idea what's actually causing this problem.

@chok
Copy link

chok commented Dec 3, 2013

Here is the result :

$ find . | wc
   7677    7677  542965

@remy
Copy link
Owner

remy commented Dec 3, 2013

Okay, that's 7600 files it's trying to bind watches too.

Can you run tree and put the result in http://pastie.org/ (only because it's going to be massive).

@chok
Copy link

chok commented Dec 3, 2013

Pastie said it's too large (more than 64kb) and after all I don't like the text at the bottom :p (All your pastes are belong to us. ). I removed some parts specific to my projects. By the way, most of files are, of course, located in node_modules.

You can find it on gist : https://gist.github.com/chok/7774318

@remy
Copy link
Owner

remy commented Dec 3, 2013

Okay, I think this is a problem entirely linked to the number of files being monitored (since you're having to bind to each individual file). I was thinking about ignoring node_modules and .git directories by default, but can you try doing it with the ignore command (assuming you're still running 0.9.x):

nodemon -i node_modules

Of course this shouldn't need to be done every time, I'm just trying to confirm this is the issue.

@chok
Copy link

chok commented Dec 3, 2013

It doesn't work :(

$ nodemon -i node_modules/ server.coffee 
3 Dec 20:52:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] 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 Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36: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)

I also try :

$ nodemon -w app/* server.coffee 
3 Dec 20:53:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] 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 Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36: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)

@remy
Copy link
Owner

remy commented Dec 3, 2013

Can you run the exact same command, but add --dump and send me the response (when you're doing the ignore version).

@chok
Copy link

chok commented Dec 3, 2013

There is no change :

$ nodemon -i node_modules/ server.coffee  --dump
3 Dec 21:17:18 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] 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 Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36: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)

@remy
Copy link
Owner

remy commented Dec 3, 2013

Hmm, sorry, can you stick --dump before your script, it should give me a dump of the config.

@chok
Copy link

chok commented Dec 3, 2013

I already tried both :(

$ nodemon -i node_modules/ --dump server.coffee 
3 Dec 21:25:35 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] 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 Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36: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)

@tjbrennan
Copy link

Hi. I don't want to sound obtuse, but when I encountered this error I fixed it by increasing max_user_watches on my system. I've been watching this thread to see if something else was going on.

@remy
Copy link
Owner

remy commented Dec 3, 2013

@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.

@tjbrennan
Copy link

@remy great, I look forward to seeing it.

@remy
Copy link
Owner

remy commented Dec 30, 2013

@chok can you try this again with nodemon@1.0.0 - nodemon now ignores .git and node_modules/**/node_modules by default, so the number of watches should be significantly lower (I'll reopen if this is still an issue).

I'm also going to try to detect the watch ENOSPC error and echo out a message about increasing max_user_watches. Not ideal, but nothing more that I can really do.

@chok
Copy link

chok commented Jan 2, 2014

I haven't this message anymore :) but now I have the problem explained in #245

@remy
Copy link
Owner

remy commented Dec 9, 2014

@alejonext can you try with npm install -g nodemon@dev - I've made quite a few changes that aren't in 1.2.1.

The error actually means "Error NO disk SPaCe" - but I think it's linked to the number of files being monitored, which should be reduced down via changes to the watching code...

@jamlfy
Copy link
Author

jamlfy commented Dec 9, 2014

@remy Works perfect :) thanks for your work!!!!

@remy
Copy link
Owner

remy commented Dec 9, 2014

Sweet. There'll be a stable release of 1.3.0 to npm likely this week with a bunch of bug fixes too.

@baio
Copy link

baio commented Dec 10, 2014

@remy astonished with response time. Thanks!

@nikopolidi
Copy link

@remy
exception in nodemon killing node
Error: watch ENOSPC
at errnoException (fs.js:1030:11)
at FSWatcher.start (fs.js:1062:11)
at Object.fs.watch (fs.js:1087:11)

node v0.10.33
OS: Linux ubuntu

@ahnbizcad
Copy link

I've fixed this with this command ember-cli/ember-cli#1240 (comment)

but is updating the package the recommended way?

I'm wondering why it got like this in the first place. I'm using node version manager with
node 0.12.0
npm 2.7.0
ember 0.2.0

@jkarttunen
Copy link

@uttampanara
Copy link

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

@ghost
Copy link

ghost commented Sep 8, 2015

I'm having this issue with "nodemon": "^1.4.1" and "node": "0.12.7" 😞

@remy
Copy link
Owner

remy commented Sep 8, 2015

Please try with #625

On Tue, 8 Sep 2015 16:20 Wesley Queiroz notifications@github.com wrote:

I'm having this issue with "nodemon": "^1.4.1" and "node": "0.12.7" [image:
😞]


Reply to this email directly or view it on GitHub
#214 (comment).

@ghost
Copy link

ghost commented Sep 8, 2015

Tried with alpha but still getting ENOSPC...
My sysctl.conf has fs.inotify.max_user_watches=10000.
If I change it to 524288 it works, but in my "dev-server" I'll not able to change it.

@remy
Copy link
Owner

remy commented Sep 8, 2015

How many files are you trying to watch? i.e. how many are under your
working directory?

On Tue, 8 Sep 2015 at 17:37 Wesley Queiroz notifications@github.com wrote:

Tried with alpha but still getting ENOSPC...
My sysctl.conf has fs.inotify.max_user_watches=10000.
If I change it to 524288 it works, but in my "dev-server" I'll not able
to change it.


Reply to this email directly or view it on GitHub
#214 (comment).

@ghost
Copy link

ghost commented Sep 9, 2015

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

@remy
Copy link
Owner

remy commented Sep 9, 2015

Yeah...so run find . | wc -l and what does that number give you? Though, it's supposed to ignore node_modules by default, it's possible it's not being taken into consideration.

@ghost
Copy link

ghost commented Sep 10, 2015

Running find . | wc -l on the root of the project gives me 18266 but when I remove node_modules and bower_components gives just 320.

@remy
Copy link
Owner

remy commented Sep 10, 2015

Okay, so I think that the watch is including the node_modules - this is part of the #625 refactor and needs to be fixed.

@remy
Copy link
Owner

remy commented Sep 10, 2015

@wesleycoder can you try with the latest nodemon@dev (it should be version 1.5.0-alpha4) and run with DEBUG=nodemon <your normal nodemon command> then paste up the full output.

@ghost
Copy link

ghost commented Sep 10, 2015

Whoa!
It works!
No errors!
Thanks!

@ankibalyan
Copy link

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

@ikrum
Copy link

ikrum commented Mar 8, 2016

@ankibalyan @uttampanara

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

@rafaelfvalim
Copy link

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

@mouthzipper
Copy link

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

@meghjoshi
Copy link

Run this command

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

@ahmdsolmn
Copy link

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.

@FossPrime
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests