You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode文件监视器ENOSPC错误咨询:无需提升fs.inotify.max_user_watches时如何终止文件监视器?/srv/路径匹配失败的正确配置模式是什么?

Fixing VSCode Watchpack ENOSPC Errors in Angular Projects

Hey there, let's work through these two file watcher issues you're facing with the ENOSPC: System limit for number of file watchers reached error in your Angular project.

1. Terminating VSCode File Watchers Without Increasing fs.inotify.max_user_watches

If you don't want to tweak system-level inotify limits, here are practical ways to reduce or stop VSCode's file watchers:

  • Disable unused extensions: Many extensions (like linters, live reload tools, or code generators) run their own file watchers. Open the Extensions panel (Ctrl+Shift+X), find extensions you're not actively using, disable them, and restart VSCode. This cuts down on redundant watchers immediately.
  • Exclude large/unnecessary folders from VSCode's watch list:
    Open VSCode Settings (Ctrl+,), search for files.watcherExclude, then click "Edit in settings.json". Add paths you don't need VSCode to monitor—common culprits are node_modules, dist, or system paths like /srv/. Example config:
    "files.watcherExclude": {
        "**/node_modules/**": true,
        "**/dist/**": true,
        "/srv/**": true,
        "**/.git/**": true
    }
    
  • Temporarily disable VSCode's core file watcher (last resort):
    Add "files.watcherEnable": false to your settings.json. Note: This disables real-time editor updates when files change, so only use this for quick fixes, not long-term development.

2. Correct Configuration to Match /srv/ Path in File Watchers

The issue likely stems from incorrect glob pattern matching. Here's how to fix it based on where you're configuring the watcher:

For VSCode's files.watcherExclude

VSCode uses glob patterns, and absolute paths need explicit root-level matching. To exclude the entire /srv/ directory and all its contents, use this pattern:

"files.watcherExclude": {
    "/srv/**": true
}
  • The / at the start ensures it matches the root-level /srv/ folder, not a folder named srv inside your project.
  • ** matches all subdirectories and files under /srv/.

For Angular's Build/Watch Configuration (angular.json)

If you're trying to exclude /srv/ from Angular's own file watcher (used during ng serve or ng build --watch), add the absolute path to the exclude array in your project's build options:

"projects": {
  "your-project-name": {
    "architect": {
      "build": {
        "options": {
          "exclude": [
            "/srv/**/*"
          ]
        }
      }
    }
  }
}
  • Double-check path case sensitivity (Linux systems are case-sensitive—if the folder is /SRV/, /srv/** won't match).
  • Ensure no more specific glob patterns are overriding your rule (e.g., if you have /srv/specific-folder/** set to be watched, it will take priority over a general /srv/** exclude rule).

内容的提问来源于stack exchange,提问作者Greg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 15:37:37