Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

388
Visualizações
Importing 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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda