美文网首页
解决Could not find a declaration f

解决Could not find a declaration f

作者: WMSmile | 来源:发表于2022-05-02 22:34 被阅读0次

    解决Could not find a declaration file for module 'vue-xxx'问题

    Could not find a declaration file for module 'vue-json-pretty'. '/Users/apple/Desktop/workspace/H5/vue/packapp/node_modules/vue-json-pretty/lib/vue-json-pretty.js' implicitly has an 'any' type. Try npm i --save-dev @types/vue-json-pretty if it exists or add a new declaration (.d.ts) file containing declare module 'vue-json-pretty';

    解决办法:

    方法一:

    为了避免这个问题,我只是用标准 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,
    

    "compilerOptions" 下面

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

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

    参考文章

    相关文章

      网友评论

          本文标题:解决Could not find a declaration f

          本文链接:https://www.haomeiwen.com/subject/hkavyrtx.html