1
votes

I have cloned the project and trying to run it for the first time in my system (Ubuntu 18.04.3 LTS) with npm serve, but I am getting the following error:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/bs-094/Dev/FPN/fpn-frontend/public'
    at FSWatcher.start (internal/fs/watchers.js:165:26)
    at Object.watch (fs.js:1258:11)
    at createFsWatchInstance (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:38:15)
    at setFsWatchListener (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:233:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:429:19)
    at FSWatcher.<anonymous> (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:477:19)
    at FSWatcher.<anonymous> (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:482:16)
    at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
    at FSWatcher._handleError (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/index.js:260:10)
    at createFsWatchInstance (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:40:5)
    at setFsWatchListener (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    [... lines matching original stack trace ...]
    at FSReqWrap.oncomplete (fs.js:154:5)

I have looked up the solution here & here, but my /etc/sysctl.conf has already fs.inotify.max_user_watches=524288 added in its last line. I have read that 524,288 is the maximum number of files that can be watched. So I am completely clueless on how to listen to my files i.e run my project.

How can I run this?

2

2 Answers

1
votes

This worked for me! First,

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

The new value can then be loaded/sourced by running:

$ sudo sysctl -p
0
votes

As increasing the limit didn't work for me, I tried a different approach. I didn't add my node_modules files to the watcher.

From my experience the best fix would be to expose the watcher configuration where one could define to ignore any folders or files of their choosing, not just node_modules.