【问题标题】:Could not find a declaration file for module 'vuetify/lib' in a fresh vue js project在新的 vue js 项目中找不到模块“vuetify/lib”的声明文件
【发布时间】:2020-07-17 15:06:31
【问题描述】:

我创建了一个新的 vue 项目,然后我添加了 vuetify,

$ vue create my-app
$ cd my-app
$ vue add vuetify
$ npm run serve

然后我得到了这个错误

ERROR in /home/ruhith/Documents/vue/file upload/fileupload/src/plugins/vuetify.ts(2,21):
2:21 Could not find a declaration file for module 'vuetify/lib'. '/home/ruhith/Documents/vue/file upload/fileupload/node_modules/vuetify/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/vuetify` if it exists or add a new declaration (.d.ts) file containing `declare module 'vuetify/lib';`
    1 | import Vue from 'vue';
  > 2 | import Vuetify from 'vuetify/lib';
      |                     ^
    3 | 
    4 | Vue.use(Vuetify);
    5 | 
Version: typescript 3.8.3
Time: 2774ms

我在这里错过了什么?这是 vuetufy 中的错误吗?

【问题讨论】:

  • "vuetify" 添加到compilerOptionscompilerOptions 中的types: [] 数组中

标签: javascript vue.js vuetify.js


【解决方案1】:

你需要将 vuetify 的类型添加到 tsconfig.json 中,像这样:

// tsconfig.json
{
  "compilerOptions": {
    "types": ["vuetify"]
  }
}

摘自此处的常见问题解答:https://vuetifyjs.com/en/getting-started/frequently-asked-questions/#questions

【讨论】:

    【解决方案2】:

    修改文件 node_modules->vuetify-loader->lib->plugin.js

    class VuetifyLoaderPlugin {
      constructor (options) {
        // this.options = options || {}
        this.options = (options) ? options : {}
      }
    

    【讨论】:

      猜你喜欢
      • 2021-03-18
      • 2020-03-04
      • 2018-08-21
      • 2019-10-22
      • 1970-01-01
      • 2023-02-23
      • 1970-01-01
      • 2021-11-30
      • 2017-08-13
      相关资源
      最近更新 更多