Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

343
Views
Import JSPDF: Uncaught SyntaxError: Cannot use import statement outside a module

I am using jsPDF and have installed it using npm and I'm importing to my javascript file however I get this error Uncaught SyntaxError: Cannot use import statement outside a module

I have tried adding module type to package.json however didn't change anything. What am I doing wrong?

UPDATE: adding type="module" to the CDN did not fix the issue either

app.js:

import {jsPDF} from "jspdf";

const pathsInstance = new Paths();

// Progressive app
if (debug === false) {
window.onload = () => {
    'use strict';

    if ('serviceWorker' in navigator) {
        navigator.serviceWorker
            .register('./pwa.js').then(reg => {
                // Trigger this after timeout
                reg.update();
            });
    }
  }
}// Event handle on page load.
window.addEventListener('load', () => {

 ....

pckage.json:

{
  "name": "board",
  "version": "1.1.0",
  "description": "Simple, standalone, flexible and very lightweight board app/PWA in JavaScript.",
  "main": "config.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/lablnet/board.git"
  },
  "author": "Muhammad Umer Farooq",
  "license": "GPL-3.0",
  "bugs": {
    "url": "https://github.com/lablnet/board/issues"
  },
  "homepage": "https://github.com/lablnet/board#readme",
  "dependencies": {
    "connect": "^3.7.0",
    "jspdf": "^2.4.0",
    "serve-static": "^1.14.1"
  }
}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!