首页 > 解决方案 > tsconfig.json 中的 **/node_modules/* 是什么意思?

问题描述

这个 Visual Code的官方文档中,建议添加node_modulesexcludetsconfig.json 的字段中。这样做是这样的:

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

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

标签: javascriptnode.jstypescriptvisual-studio-codeeslint

解决方案


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

从他们的文档中:

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

推荐阅读