13

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.

slanden
  • 1,199
  • 2
  • 15
  • 35
  • @GinoMempin Thank you, but I'm glad I didn't. The "solution" proved to not work after all, and this way I'm not leading anyone astray. – slanden Jan 01 '20 at 06:00
  • I edited the update section to hopefully be less confusing. – slanden Jan 02 '20 at 17:22
  • 8192 is way too few inotify listeners. No reason not to increase it to 500K on a modern system. – oligofren Mar 02 '21 at 12:50
  • 2
    Just linking this, https://github.com/Microsoft/vscode/issues/40898 but unfortunately it is closed. I'm still experiencing this problem and it is late 2022. I'm going to up the limit, but it is stupid that the node_modules cannot be excluded. – John Forbes Oct 06 '22 at 01:14
  • The trick for me was deleting node_modules after adding the entry to vscode settings and finally restarting vscode. – java-addict301 Feb 16 '23 at 15:37

1 Answers1

-3

If feasible, you could disable the built-in extension: TypeScript and JavaScript Language Features, but that would remove some features that might take away the whole point of using vscode.

mdmundo
  • 1,988
  • 2
  • 23
  • 37