32

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?

Evan Carroll
  • 71,692
  • 44
  • 234
  • 400
MikhilMC
  • 623
  • 3
  • 7
  • 12

6 Answers6

77

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
Evan Carroll
  • 71,692
  • 44
  • 234
  • 400
user3294794
  • 779
  • 4
  • 4
11

I found this post and helped me to solve that problem. All you have to do is change the max_user_watches

Error ENOSPC System limit for number of file watchers reached

Alan Mejia
  • 161
  • 1
  • 4
3

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
},
brando f
  • 53
  • 6
2

Use below

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

To increase the number of watches by your system

Prabhat Mishra
  • 838
  • 1
  • 12
  • 28
Jasper
  • 131
  • 3
1

# 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
abdulalim
  • 126
  • 1
  • 4
0

I got this error in VS Code and checked that already had the files.watcherExclude options listed here. I found some alternatives to avoid this error, these may be helpful if you prefer not to increase the max-user-watches value.

  • Abstain from start many servers at the same time. Start only one Angular server at a time.
  • Abstain from open many folders at the same time in VSCode. If there is only one project, try opening a sub folder to reduce watches. (I started one server and opened two projects and the error showed up minutes later).
  • Avoid using VSCode terminal to start the Angular server, because it may be slower than the Linux terminal.
  • If the error is still appearing, and restarting VSCode with the above suggestions does not work, try restarting your machine to kill possible useless processes.

I hope it helps.

LMigMa49
  • 1
  • 3