I'm struggling to solve this issue. I've been attempting to create a program that can download a pdf from a webpage using the jsPDF npm module.
After downloading it, I tried importing it in two different ways:
- Using the node.js require statement
const pdf = require("jsPDF");
When I ran it with the web server, I realized that the require statement is not supported. So, I turned to browserify to compile it into a bundle.js and encountered a large error message:
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module'
at DestroyableTransform.end [as _flush]
at DestroyableTransform.prefinish
... (additional error lines)
All these errors were pointing to various files within the browserify package.
- Trying to import through the default javascript import statement
import {jsPDF} from "jsPDF";
This resulted in an error message stating:
Failed to resolve module specifier "jspdf". Relative references must start with either "/", "./", or "../".
I am using the Live Server vscode plugin for running the server, and I'm unsure of what steps to take next.
Any assistance on this matter would be greatly appreciated.