Vue and pdfkit generates an error: not constructor

2.5k Views Asked by At

I installed pdfkit in my Vue.js app then I created a vue component to start creating PDF but on my first test I got an error:

Component script:

const pdfkit =  require('pdfkit');
var doc = new pdfkit;

But this generates an error:

pdfkit is not a constructor

How to fix it? Thanks for any suggetsion

1

There are 1 best solutions below

3
On BEST ANSWER

Try to import it in your component with

import pdfkit from 'pdfkit'

and then create your document with

let doc = new pdfkit();