[Solved] gulp watch error – ENOSPC

While I was working on one of my project, I got the following error while trying to run gulp watch.

[11:59:02] Using gulpfile ~/projects/gulpfile.js
[11:59:02] Starting 'watch'...
[11:59:02] 'watch' errored after 55 ms
[11:59:02] Error: watch /home/developer/projects/resources/assets/sass/ ENOSPC
    at exports._errnoException (util.js:870:11)
    at FSWatcher.start (fs.js:1234:19)
    at Object.fs.watch (fs.js:1262:11)
    at Gaze._watchDir (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:289:30)
    at /home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:358:10
    at iterate (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)
    at Object.forEachSeries (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:66:3)
    at Gaze._initWatched (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:354:10)
    at Gaze.add (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:177:8)
    at new Gaze (/home/developer/projects/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:74:10)

After doing some google found the solution.

Why this issue occured? There is the limit in the number of files that can be watched in a system. We have to increase this number. The below command can be used to increase this number.

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

Related Links
https://github.com/gulpjs/gulp/issues/217

One thought on “[Solved] gulp watch error – ENOSPC

Leave a Reply

Your email address will not be published. Required fields are marked *