我正在尝试在Visual Studio代码中的“浏览”选项卡上排除多个文件夹。为此,我在项目的根目录中添加了以下jsconfig.json:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules"
]
}
但是“node_modules”文件夹仍然在目录树中可见。我究竟做错了什么?还有其他选择吗?
workspace settings
标签settings.json
文件中:
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"**/.git": true, // this is a default value
"**/.DS_Store": true, // this is a default value
"**/node_modules": true, // this excludes all folders
// named "node_modules" from
// the explore tree
// alternative version
"node_modules": true // this excludes the folder
// only from the root of
// your workspace
}
}
如果选择“文件” - >“首选项” - >“用户设置”,则可以为当前用户全局配置排除的文件夹。
settings.json
更改排除设置:{}
。另请查看settings.json
和,因为它们也可能有用。此代码段包含其解释和默认值:
files.exclude
有关其他设置的更多详细信息,请参阅search.exclude
。
在Visual Studio Code 1.28版中,files.watcherExclude
必须放在{
// Configure glob patterns for excluding files and folders. For example, the files explorer decides which files and folders to show or hide based on this setting. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
// Configure glob patterns for excluding files and folders in searches. 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
},
// 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.
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
}
}
节点内。
导致工作区文件看起来像:
official settings.json
reference
在较新版本的VSCode中,这移动到特定于文件夹的配置块。
然后添加一个“files.exclude”块,列出要排除的目录globs:
"files.exclude"
settings
我设法通过禁用验证来删除错误:
{
"settings": {
"files.exclude": {
"**/node_modules": true
}
}
}
Obs:我的项目是使用StyledComponents,React,Flow,Eslint和Prettier的PWA。