jsconfig.json gives ts errors

Mik*_*uge 9 vue.js visual-studio-code nuxt.js vscode-jsconfig

I am having jsconfig.json in my root directory using Nuxt.js project. And I am having an error:

File '/home/mike/Documents/nuxt/node_modules/dotenv/types' not found.
  The file is in the program because:
    Root file specified for compilation
Run Code Online (Sandbox Code Playgroud)

Actually 5 errors in a first line of jsconfig.json: 错误

I don't even use typescript and I didn't set any typescript options while creating Nuxt.js project

jsconfig.json content:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"],
      "@/*": ["./*"],
      "~~/*": ["./*"],
      "@@/*": ["./*"]
    }
  },
  "exclude": ["node_modules", ".nuxt", "dist"]
}
Run Code Online (Sandbox Code Playgroud)

I don't understand where they come from. How do I get rid of this errors? There's no option quick fix so I can't ignore errors for entire file

小智 15

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


Mat*_*fer 10

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

我最初是从 via 开始的code .,所以我想可能出现错误的实例从我的终端中获取了一个奇怪的环境变量。


Sal*_*man 5

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


小智 2

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

 npm install --save @types/dotenv
Run Code Online (Sandbox Code Playgroud)

  • 手动添加类型会发出警告“npm WARN deprecated @types/dotenv@8.2.0:这是一个存根类型定义”。dotenv 提供了自己的类型定义,因此您不需要安装它。 (2认同)