【问题标题】:Project-wide Javascript/TypeScript language error from built-in language extension来自内置语言扩展的项目范围的 Javascript/TypeScript 语言错误
【发布时间】:2020-04-26 11:09:14
【问题描述】:

每当我打开工作区时,我都会在 VSCode 中收到以下错误。

To enable project-wide JavaScript/TypeScript language features, exclude large folders with source files that you do not work on. 
Source: TypeScript and Javascript Language Feat... [BUTTON: CONFIGURE EXCLUDES]

我单击消息上的Configure Excludes 按钮,它会打开以下文件 FRONTENDAPP/jsconfig.json

{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]}

在我看来,根据以下文档正确配置。 :https://code.visualstudio.com/docs/languages/javascript

那为什么总是报错呢?

我的工作区设置如下:

FOLDER: NOTES
FOLDER: FRONTENDAPP
FOLDER: BACKENDAPP

每个文件夹作为一个jsconfig.json 文件。

NOTES 和 BACKENDAPP 中的相应文件相同,如下所示:

{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]}

【问题讨论】:

  • 听起来您的每个应用文件夹中仍有大文件夹。
  • 你的工作区有多少个 JS/TS 文件?
  • 检查文件计数给了我正确的策略。 @MattBierner。我找到了一个文件夹,里面有不少js文件,现在已经排除了。

标签: javascript typescript visual-studio-code vscode-settings


【解决方案1】:

我遇到了同样的问题,我意识到:

  1. 我在子文件夹中有node_modules
  2. 我有 dist 的副本(如 dist1dist2)用于调试,其中 gitignored 但未忽略 vscode。
  3. 我有 .npm.npm-tmp 文件夹,里面有很多东西。
  4. 除了dist,我还有另一个tmp文件夹.app-cache

我最终在/jsconfig.json 中添加了以下条目(为了便于阅读,这有点多余)以使警告消失:

  "exclude": [
    ".git",
    ".app-cache",
    ".npm",
    ".npm-tmp",
    "dist",
    "dist*",
    "node_modules",
    "subfolder/dist",
    "subfolder/node_modules",
    "**/dist/*",
    "**/node_modules/*",
  ]
}

【讨论】:

    【解决方案2】:

    识别包含大量文件的文件夹: du -a | cut -d/ -f2 | sort | uniq -c | sort -nr

    162114 node_modules
    5837 .git
    4967 concat-stats-for
     443 app
      77 tests
      72 dist
       8 config
       7 public
    

    检查 jsconfig.json 中未排除的文件夹中的 JS 和 TS 文件

    find concat-stats-for -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -n | grep -Ei '(js|ts)$'
    
      42 ts
    3003 js
    

    如果文件夹不是应用程序代码,请将所述文件夹添加到jsconfig.json排除。

    【讨论】:

      猜你喜欢
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多