Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cannot find module 'jspdf-autotable' and 'jspdf' or its corresponding type declarations

mycomponent.ts

import  jsPDF  from 'jspdf';
import autoTable from 'jspdf-autotable';

export class Component implements OnInit {
.
.
.
 exportPdf() {

    const doc = new jsPDF('p', 'pt');
 columns = [...]

    autoTable(doc, {
      columns: this.columns,
      body: this.data,
      didDrawPage: (dataArg) => {
        doc.text('data', dataArg.settings.margin.left, 10);
      }
    });
    doc.save('data.pdf');
  }
}

package.json

 "dependencies": {

    "jspdf": "^2.5.1",
    "jspdf-autotable": "^3.5.23"

}
 

I installed my npm packages with npm i jspdf and npm i jspdf-autotable but the same errors persist. I don’t understand what should I do. Are the versions wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to install @types/jspdf and @types/jspdf-autotable as dev-dependencies.

If you use yarn:

yarn add -D @types/jspdf @types/jspdf-autotable

For npm use:

npm install @types/jspdf @types/jspdf-autotable --save-dev
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading