我想知道为什么我的 node_modules 文件夹在我运行命令后在我的 VS Code 编辑器中显示为灰色npm install。
这是我文件夹的图片:
正如已经指出的,VSCode 自动忽略.gitignore. 但是,它默认也会明确忽略某些文件夹。所有这些都可以配置。以下是您可能想要采取的步骤:
User(全局)和之间进行选择Workspace)。我通常通过CTRL(或Command在 Mac 上) + SHIFT+ P->执行此操作> settings,这将向您显示相关选择:
。对于每一个,您都可以选择 UI 或JSON变体。Peferences: Open Default Settings (JSON)。您会发现,截至目前(2021 年 5 月),**/node_modules也被自动排除,独立于其他忽略文件。目前默认设置如下所示:
// Configure glob patterns for excluding files and folders in fulltext searches and quick open. Inherits all glob patterns from the `files.exclude` setting. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
// Controls whether to use global `.gitignore` and `.ignore` files when searching for files.
"search.useGlobalIgnoreFiles": false,
// Controls whether to use `.gitignore` and `.ignore` files when searching for files.
"search.useIgnoreFiles": true,
Run Code Online (Sandbox Code Playgroud)
node_modules "search.exclude": {
"**/node_modules": false
},
"search.useIgnoreFiles": false
Run Code Online (Sandbox Code Playgroud)
node_modules需要永远进行搜索 - 至少在冷启动期间,即未缓存内容时。(请注意,很难估计它们的缓存是如何工作的,因为它随着时间的推移而不断发展。)search.exclude设置。请注意,您必须明确列出您不想要的所有内容,因为......search.exclude不支持:
这样的事情是行不通的!
// does NOT work! :((
"search.exclude": {
"**/node_modules/@types": false,
"**/node_modules": true
}
Run Code Online (Sandbox Code Playgroud)
这是一个重大问题,在几乎著名的#869 期中已经被广泛讨论了6 年!加入并添加 100 多条评论!:)
更新:截至 2021 年 8 月 14 日,该问题已从积压队列中删除并放入On Deck队列中(但这也可能没有多大意义)。
| 归档时间: |
|
| 查看次数: |
8024 次 |
| 最近记录: |