likes
comments
collection
share

解决Could not find a declaration file for module 'vu

作者站长头像
站长
· 阅读数 33

问题描述

ERROR in src/main.ts:6:21
TS7016: Could not find a declaration file for module 'vue-ls'. 'E:/123/node_modules/vue-ls/dist/vue-ls.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/vue-ls` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-ls';`
    4 | import Vue from 'vue'
    5 | import App from './App.vue'
  > 6 | import Storage from 'vue-ls'
      |                     ^^^^^^^^
    7 | import router from './router'
    8 | import store from './store/'

解决办法:

方法一:

为了避免这个问题,我只是用标准 require() 替换它

This error occured because of vue-xxxxxx has been generated in JavaScript.

const vue-xxxxxx = require('vue-xxxxxx');
// import { vue-xxxxxx } from 'vue-xxxxxx'

方法二:

为了避免这个问题,我只是在 tsconfig.json 中修改了这些行

"noImplicitAny": false,
"allowJs": true,

现在您可以使用 import 语句,如下所示

import { vue-xxxxxx } from 'vue-xxxxxx'