VSCode jsconfig.json 给出 ts 错误指定用于编译的根文件

Gre*_*nov 14 visual-studio-code

我已经在 stackoverflow jsconfig.json 给出 ts 错误上寻找答案。\n我尝试过:

\n
    \n
  1. \n
\n
"exclude": ["node_modules"]\n
Run Code Online (Sandbox Code Playgroud)\n

在 jsconfig.json 中

\n
    \n
  1. \n
\n
"noEmit": true \n
Run Code Online (Sandbox Code Playgroud)\n

在 jsconfig.json 中的“compilerOptions”中

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

    \n
  2. \n
  3. \n
\n
npm install --save @types/dotenv\n
Run Code Online (Sandbox Code Playgroud)\n

没有任何帮助:(

\n

我只使用 js 文件或 jsx。我的操作系统 ubuntu (Focal Fossa)。\xd0\xa1an 有人向我解释错误来自哪里。它与 TypeScript 有什么关系?如何彻底摆脱它?除了上面已经做的事情之外,我还能做什么?

\n

完整的错误消息是:

\n
{\n    "resource": "path/jsconfig.json",\n    "owner": "typescript",\n    "severity": 8,\n    "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",\n    "source": "ts",\n    "startLineNumber": 1,\n    "startColumn": 1,\n    "endLineNumber": 1,\n    "endColumn": 2\n}\n
Run Code Online (Sandbox Code Playgroud)\n

小智 10

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

  • 由于在搜索相同问题但使用 typescript 文件和“tsconfig.json”时会弹出此答案,因此这可能听起来很明显,但如果您正在使用 typescript 文件,请不要禁用此设置。不过我还没有找到解决方案。 (2认同)