【uniapp】template标签后报错写入全局类型文件失败

515 阅读1分钟

报错信息:

Write global types file failed. Please ensure that "node_modules" exists and "vue" is a direct dependency, or set "vueCompilerOptions.globalTypesPath" in "tsconfig.json" add.vue(404)

原因就是uniapp 用hbuilder X方式开发, 会自动处理依赖,在基于vscode编辑器里会识别不到依赖文件。导致报错

有人提了issues: vue-issues 点击查看

解决方法:

在3.0.2版本中为没有node_modules的项目新建 jsconfig.json 文件 正如 [#5505](#5505) 所描述,为 jsconfig.json 文件中添加

{
  "vueCompilerOptions": {
    "globalTypesPath": "./vue-global-types.d.ts"
  }
}