Skip to content

Cannot find module 'jspdf' or its corresponding type declarations #3129

@lartheon

Description

@lartheon

I'm using VueJS with Typescript. I've just installed v2.3.1 and imported it using

import { jsPDF } from "jspdf";

export default Vue.extend({
   methods: {
       async print(): Promise<void> {
          const doc = new jsPDF(); // this line throws a compile error "Can't resolve 'jspdf'"
      },
   }
})

But this has produced the following errors

Cannot find module 'jspdf' or its corresponding type declarations.
frontend       |     246 | import { mapGetters } from "vuex";
frontend       |     247 | import Vue from "vue";
frontend       |   > 248 | import { jsPDF } from "jspdf";

I didn't think I needed to but I tried anyway installing the @types/jspdf package but that hasn't resolved the issue.
Again didn't think I would need to but I thought I'd try it anyway, I created a index.d.ts file, and import in my tsconfig.json, nothing has worked. I've since removed those.

This dependency was not found:
frontend       |
frontend       | * jspdf in ./node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--14-2!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/htmlToPDF.vue?vue&type=script&lang=ts&
frontend       | No type errors found
frontend       | Version: typescript 4.2.3

The package appears to be installed, I can ctrl+left click on the package name and read the package's index.d.ts file.

Any suggestions?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions