【发布时间】:2019-12-31 17:54:26
【问题描述】:
在 VS Code 中,我有一个少于 50 个文件的 Vue 项目,但在运行开发服务器时 VS Code 会抛出 Error: ENOSPC: System limit for number of file watchers reached。
我的 VS Code Watcher 排除设置具有以下忽略模式。
**/.git/objects/**
**/.git/subtree-cache/**
**/node_modules/**
我试图找出哪些文件可能使我超过了我机器上的 max_user_watches 限制,即 8192。
通过另一个用户“oligofren”的StackExchange answer from user "mosvy" 和script derived from that answer,我发现以下来源可能会导致此问题。
| 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 |
我不确定为什么要监视其中的任何一个,但前两个似乎忽略了 VS Code 的 Watcher Exclude 设置 **/node_modules/**
如果可能,在 VS Code 的 Watcher Exclude 设置中排除所有这三个是否安全?
我不想破坏我的 VS Code 安装。
更新
上面的 Watcher Exclude 设置是 VS Code 列出的默认设置。我添加了相同的设置
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true
}
直接到 settings.json 文件,上面列出的两个 node_modules 源被删除,该会话的错误消失了。
重启 VS Code 并验证 settings.json 仍然包含我所做的更改后,不再排除之前的两个 node_modules 源。
【问题讨论】:
-
@GinoMempin 谢谢,但我很高兴我没有这样做。 “解决方案”最终被证明是行不通的,这样我就不会把任何人误入歧途。
-
我编辑了更新部分,希望能减少混乱。
-
8192 的 inotify 听众太少了。在现代系统上没有理由不将其增加到 500K。
标签: visual-studio-code vscode-settings inotify