【问题标题】:jsconfig.json gives ts errorsjsconfig.json 给出 ts 错误
【发布时间】:2021-06-26 08:03:09
【问题描述】:

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

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

jsconfig.json的第一行其实有5个错误:

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

jsconfig.json内容:

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

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

【问题讨论】:

    标签: vue.js visual-studio-code nuxt.js vscode-jsconfig


    【解决方案1】:

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

    【讨论】:

    • 你试过把它放在jsconfig.json上吗?
    • 老实说,我不记得我做了什么,但错误消失了。
    • 将其添加到 jsconfig.json 后似乎可以正常工作。
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

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

       npm install --save @types/dotenv
      

      【讨论】:

      • 感谢您的建议,但我刚刚初始化了github repo,问题就消失了。如果问题再次出现,我会尝试您的解决方案。
      • 我想通了,错误消息出现在重新开始(当我运行我的 PC 并打开 VSCode 时),一旦我提交对我的 GitHub 存储库的更改,错误消息就会消失。你知道为什么会这样吗?
      • 奇怪的行为,不知道为什么,但我会建议按照上面的建议安装“类型”或删除 node_modules 和 package-lock.json 并安装新的 npm。
      • 手动添加类型会发出警告npm WARN deprecated @types/dotenv@8.2.0: This is a stub types definition. dotenv provides its own type definitions, so you do not need this installed.
      猜你喜欢
      • 2021-10-23
      • 2021-07-04
      • 1970-01-01
      • 2020-11-10
      • 1970-01-01
      • 2020-08-21
      • 1970-01-01
      • 2023-02-05
      • 2020-11-30
      相关资源
      最近更新 更多