有没有办法在 node_modules 文件夹内为 vscode-languageclient 监视文件系统事件?

Is there a way to watch file system events inside node_modules folder for vscode-languageclient?

在扩展 activate(context:ExtensionContext) 函数中,我想添加一个 FileSystemWatcher。虽然这适用于例如

const clientOptions: LanguageClientOptions = {
      documentSelector: [{scheme: 'file', language: 'plainText'}],
      synchronize: {
           fileEvents: vscode.workspace.createFileSystemWatcher('**/someFolder/*.txt')
      }
}

如果我现在想观看 node_modules 文件夹中的文件,没有任何反应..知道吗?

有一个具有以下默认值的 "files.watcherExclude" 设置:

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

Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths (i.e. prefix with ** or the full path to match properly). Changing this setting requires a restart. When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load.

从性能方面考虑,可能也不建议从此处删除 node_modules,因为它可能包含很多文件。在任何情况下,由于它是用户设置,作为扩展作者,您无法控制它。