Visual Studio Code:无法监视文件更改。为什么?

Jet*_*tte 4 visual-studio-code

我经常收到“Visual Studio Code 无法观察这个大工作区中的文件更改”的错误消息,我不知道为什么。

Visual Studio Code (Linux): 1.24.1
Run Code Online (Sandbox Code Playgroud)

我的排除设置是:

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/.svn/**": true,
    "**/dist/**": true,
    "**/dist-prod/**":true
}
Run Code Online (Sandbox Code Playgroud)

该项目的结构是:

angular.json
/dist
/dist-prod
/e2e
ngsw-config.json
/node_modules
package.json
package-lock.json
proxy.conf.json
README.md
/src
tsconfig.json
tslint.json
xliffmerge.json
.editorconfig
.gitignore
/.svn
Run Code Online (Sandbox Code Playgroud)

/src 仅包含 167 个文件和文件夹。我怀疑 node_modules 并没有真正被排除在外。但我不能确定。我的设置正确吗?

重新启动 VSC 后问题消失了,但过一段时间总是会出现...

Ana*_*aja 5

你必须增加限制。请按照以下步骤操作:

  1. 检查电流限制 cat /proc/sys/fs/inotify/max_user_watches
  2. 在 vim 编辑器中编辑 sysctl.conf 文件 sudo vim /etc/sysctl.conf
  3. 在底部添加这一行 fs.inotify.max_user_watches=524288
  4. 保存(ESC) :wq!
  5. 加载更改 sudo sysctl -p
  6. 现在再次检查 cat /proc/sys/fs/inotify/max_user_watches

如果计数相同,则执行以下命令

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Run Code Online (Sandbox Code Playgroud)

更多细节

快乐编码:)

  • 增加 max_user_watches 似乎是处理症状的一种方法。它不能治愈潜在的疾病。15个月前,当我写这个问题时,我想知道“观察者排除”功能是否有错误。我将其配置为排除 node_modules 和它应该忽略的其他文件夹。显然,在包含 167 个文件的小项目中没有必要增加 max_user_watches。当我观看输出时,在我看来,它处理的文件比这多得多......这个错误很可能得到修复。有一天我会减少 max_user_watches 来检查它。 (2认同)