【问题标题】:VSCode jsconfig.json gives ts errors Root file specified for compilationVSCode jsconfig.json 给出 ts 错误 指定编译的根文件
【发布时间】:2021-10-23 01:09:22
【问题描述】:

我已经在 stackoverflow jsconfig.json gives ts errors 上寻找答案。 我试过了:

  1. 设置
"exclude": ["node_modules"]

在 jsconfig.json 中

  1. 设置
"noEmit": true 

在“compilerOptions”中的 jsconfig.json 中

  1. 删除 node_moduls 和 package-lock.json 并在 npm install 之后

npm install --save @types/dotenv

没有任何帮助:(

我只使用 js 文件或 jsx。我的操作系统 ubuntu(Focal Fossa)。 Сan有人向我解释错误来自哪里。它与 TypeScript 有什么关系。以及如何完全摆脱它?除了上面已经做过的,我还能做什么?

完整的错误信息是:

{
    "resource": "path/jsconfig.json",
    "owner": "typescript",
    "severity": 8,
    "message": "File 'path/node_modules/agent-base/dist/src/index' not found.\n  The file is in the program because:\n    Root file specified for compilation",
    "source": "ts",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 2
}

【问题讨论】:

  • 我也遇到了同样的问题,到目前为止,我遇到的任何解决方案都没有奏效......
  • 我有完全相同的问题,但还没有答案。忽略我发布然后删除的答案。我发现它毕竟不起作用。

标签: visual-studio-code vscode-settings


【解决方案1】:

您可以在 Visual Studio 中使用以下方法作为解决方法。 文件 > 首选项 > 设置,在搜索栏中输入“typescript validate”,然后取消选中结果。

【讨论】:

    【解决方案2】:

    我实际上遇到了类似的问题,我通过更改 VS Code 中的 TypeScript 版本设法解决了这个问题。只需打开任何 JavaScript 文件,然后单击右下角的“选择语言模式”按钮。它应该允许您选择工作区 TS 版本而不是全局版本。

    【讨论】:

      猜你喜欢
      • 2021-06-26
      • 2022-01-12
      • 2018-07-22
      • 2019-02-15
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      相关资源
      最近更新 更多