Error: ENOSPC: System limit for number of file watchers reached angular

Viewed 44721

I am getting this error while doing my Angular 10 project.

Error from chokidar (/myProject): Error: ENOSPC: System limit for number of file watchers reached, watch '/myProject/tsconfig.spec.json'

Is there a method to resolve this error?

5 Answers

You're running into a kernel limit with your inotify watchers. You can run this to fix it for the current boot,

sudo sysctl -w fs.inotify.max_user_watches=524288

You can run this to fix it for future boots,

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

I got this in vs code when doing ssh. I think the problem was that vs code was watching all the files in my node_modules folder. To solve this in vs code I went to:

File > Preferences > Settings, and then to the little paper icon at the top of the settings page. This takes you to the settings.json file vs code uses. Then I added this to the settings file and it solved the problem:

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true,
    "**/samples": true
},

Use below

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

To increase the number of watches by your system

# 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 new value was applied

cat /proc/sys/fs/inotify/max_user_watches
Related