Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Error: ENOSPC: System limit for number of file watchers reached

I have setup a new blank react native app.

After installing few node modules I got this error.

Running application on PGN518. internal/fs/watchers.js:173    throw error;    ^  Error: ENOSPC: System limit for number of file watchers reached, watch '/home/badis/Desktop/react-native/albums/node_modules/.staging'    at FSWatcher.start (internal/fs/watchers.js:165:26)    at Object.watch (fs.js:1253:11)    at NodeWatcher.watchdir (/home/badis/Desktop/react-native/albums/node modules/sane/src/node watcher. js:175:20)    at NodeWatcher.<anonymous> (/home/badis/Desktop/react-native/albums/node modules/sane/src/node watcher. js:310:16)    at /home/badis/Desktop/react-native/albums/node modules/graceful-fs/polyfills.js:285:20    at FSReqWrap.oncomplete (fs.js:154:5) 

I know it's related to no enough space for watchman to watch for all file changes.

I want to know what's the best course of action to take here ?

Should I ignore node_modules folder by adding it to .watchmanconfig ?

like image 346
Badis Merabet Avatar asked Apr 19 '19 14:04

Badis Merabet


People also ask

How do I fix error Enospc system limit for the number of watchers reached watch?

You can fix it, that increasing the amount of inotify watchers. Then paste it in your terminal and press on enter to run it.


1 Answers

Linux uses the inotify package to observe filesystem events, individual files or directories.

Since React / Angular hot-reloads and recompiles files on save it needs to keep track of all project's files. Increasing the inotify watch limit should hide the warning messages.

You could try editing

# insert the new value into the system config echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p  # check that the new value was applied cat /proc/sys/fs/inotify/max_user_watches  # config variable name (not runnable) fs.inotify.max_user_watches=524288 
like image 184
Abdulla Thanseeh Avatar answered Oct 10 '22 04:10

Abdulla Thanseeh