31

jsconfig.json在我的根目录中使用Nuxt.js项目。我有一个错误:

File '/home/mike/Documents/nuxt/node_modules/dotenv/types' not found.
  The file is in the program because:
    Root file specified for compilation

实际上第一行有5个错误jsconfig.json错误

我什至没有使用typescript,也没有typescript在创建时设置任何选项Nuxt.js project

jsconfig.json内容:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"],
      "@/*": ["./*"],
      "~~/*": ["./*"],
      "@@/*": ["./*"]
    }
  },
  "exclude": ["node_modules", ".nuxt", "dist"]
}

我不明白他们是从哪里来的。我该如何摆脱这个错误?没有选择quick fix所以我不能ignore errors for entire file

4

5 回答 5

19

在尝试了几种解决方案后,我刚刚添加"exclude": ["node_modules"]并重新启动了 VScode。错误消失了。

于 2021-05-24T20:04:56.460 回答
8

我遇到了这个问题,只是退出并重新启动 VSCode(从图标)似乎可以解决它。

我最初是从 via 开始的,code .所以我想也许有错误的实例从我的终端中获取了一个奇怪的 env var。

于 2021-09-02T01:57:07.280 回答
8

ctrl + shift + p只需通过键入然后键入重新加载 VSCode reload window,它应该可以工作。

于 2022-01-26T15:19:39.327 回答
2

尝试安装和重建项目,希望这会有所帮助,

 npm install --save @types/dotenv
于 2021-03-30T10:24:02.873 回答
2

就我而言,问题在于该项目位于 monorepo 内的子文件夹中。

所以解决方案是将其更改为 add ./before node_modules

"exclude": ["./node_modules", ".nuxt", "dist"],
于 2022-02-06T07:20:27.337 回答