Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

347
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda