tsconfig.json中的**/node_modules/*是什么意思?

What it means **/node_modules/* in tsconfig.json?

this official docs of Visual Code中,建议将node_modules添加到tsconfig.json的exclude字段。它是这样完成的:

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true
  },
  "exclude": ["node_modules", "**/node_modules/*"]
}

我想知道如果我已经添加了普通 node_modules 文件夹,为什么还需要 **/node_modules/*

**/node_modules/* 是一个 glob 模式,意思是(从右到左)“node_modules 目录下的任何内容 在任何深度 ”。有关更多详细信息,请参阅 glob 模块,它很可能是用于解释该模式的模块。

来自他们的文档:

  • * 匹配单个路径部分中的 0 个或多个字符
  • ** 如果“globstar”单独出现在路径部分,则它会匹配零个或多个目录和子目录以搜索匹配项。它不会抓取符号链接目录。