NodeJs fs.watch/FSWatcher Error

Hello I Use the following,

Ubuntu 17.04 Node: v6.11.2 NPM: v3.10.10

While installing My project dependencies I get warning on installing fsevents(this error. I ignored that and I ran the project using Gulp.

I get the following error,

events.js:160
  throw er; // Unhandled 'error' event
  ^
Error: watch /media/app/modules/services/auth/ ENOSPC
    at exports._errnoException (util.js:1020:11)
    at FSWatcher.start (fs.js:1443:19)
    at Object.fs.watch (fs.js:1470:11)
    at Gaze._watchDir (/media/node_modules/gaze/lib/gaze.js:289:30)
    at /media/node_modules/gaze/lib/gaze.js:358:10
    at iterate (/media/node_modules/gaze/lib/helper.js:52:5)
    at /media/node_modules/gaze/lib/helper.js:61:11
    at /media/node_modules/gaze/lib/gaze.js:420:5
    at iterate (/media/node_modules/gaze/lib/helper.js:52:5)
    at /media/node_modules/gaze/lib/helper.js:61:11
    at /media/node_modules/gaze/lib/gaze.js:420:5
    at iterate (/media/node_modules/gaze/lib/helper.js:52:5)
    at /media/node_modules/gaze/lib/helper.js:61:11
    at /media/node_modules/gaze/lib/gaze.js:420:5
    at iterate (/media/node_modules/gaze/lib/helper.js:52:5)
    at /media/node_modules/gaze/lib/helper.js:61:11

I get this only in this machine I am using. The projects runs well on other systems.

Can anyone help me to solve this?

Answers

I was facing this problem for most of my project when running with gulp. Only way I could get through was restarting my system again. But then found the root cause and a fix in the below article. https://github.com/facebook/jest/issues/3254#issuecomment-297214395
The command to fix this problem is

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

Posted on by Vik