Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code not excluding Code's node_modules from being watched - file watch limit reached

In VS Code, I have a Vue project with less than 50 files but upon running the dev server VS Code throws Error: ENOSPC: System limit for number of file watchers reached.

My VS Code Watcher Exclude settings have the following ignore patterns.

**/.git/objects/**
**/.git/subtree-cache/**
**/node_modules/**

I tried to figure out what files could possibly be setting me over the max_user_watches limit on my machine, which is 8192.

With a StackExchange answer from user "mosvy" and a script derived from that answer by another user "oligofren", I've found that the following sources are likely causing this.

| Watchers | Source                                                                                                                   |
| -------- | ------                                                                                                                   |
| 4033     | /usr/share/code/code --max-old-space-size=3072 /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsse |
| 3889     | /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTy |
| 99       | /usr/share/code/code /usr/share/code/resources/app/out/bootstrap-fork --type=watcherService                              |

I'm not sure why any of these are being watched, but the first two seem to be ignoring VS Code's Watcher Exclude setting of **/node_modules/**

If possible, is it safe to exclude all three of these in the Watcher Exclude settings of VS Code?

I don't want to break my VS Code install.

Update

The Watcher Exclude settings above are what VS Code has listed as default. I added the same settings

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

directly to the settings.json file and the two node_modules sources listed above were removed and the error went away for that session.

After restarting VS Code and verifying that settings.json still included the changes I made, the two node_modules sources from before are no longer being excluded.

like image 531
slanden Avatar asked Dec 05 '25 04:12

slanden


1 Answers

Fought against the same issue for the best part of today, the solution in my case was that the default VSCode setting actually didn't work:

"files.watcherExclude": {
    ...
    "**/node_modules/*/**": true,
    ...
},

VSCode was still watching everything in node_modules, while the setting given by OP did work:

"files.watcherExclude": {
    ...
    "**/node_modules/**": true
    ...
},
like image 106
Wouzz Avatar answered Dec 08 '25 06:12

Wouzz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!