Webpack error with jsPDF in laravel/vuejs mix

Viewed 1089

So I'm trying to use jsPDF in my project but whenever I'm trying to import jsPDF to my vue component I get this error:

ERROR in ./node_modules/canvg/lib/index.es.js 1933:16-23
Module not found: Error: Can't resolve 'process/browser' in '/Users/air-1/Desktop/OneDrive - laravel projects/prevzemniDokumenti/node_modules/canvg/lib'
Did you mean 'browser.js'?
BREAKING CHANGE: The request 'process/browser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

webpack compiled with 1 error

Now it says I have to add the extension to the request but I have no idea what it means by that... Tried to look for solution but i cannot find one So now I am here.

my package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "autoprefixer": "^10.3.7",
        "axios": "^0.21",
        "jquery": "^3.6",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "popper.js": "^1.16.1",
        "postcss": "^8.3.9",
        "resolve-url-loader": "^3.1.2",
        "tailwindcss": "^2.2.16",
        "vue": "^2.6.12",
        "vue-loader": "^15.9.8",
        "vue-template-compiler": "^2.6.12"
    },
    "dependencies": {
        "jspdf": "^2.4.0",
        "vue-router": "^3.5.2"
    }
}

How can i solve this error?

1 Answers
Related