jsPDF: Uncaught SyntaxError: Unexpected token ;

I am using jsPDF trough import {jsPDF} from 'jspdf'; (Webpack) And after I do this, I get an error: jspdf.min.js?b003:273 Uncaught SyntaxError: Unexpected token ;

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 28 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@simonbengtsson Just ran into this today but I did confirm that cloning and rebuilding seems to fix the issue:

import jsPDF from '../../node_modules/jspdf/dist/jspdf.min';

I updated the build script now and it includes fixes for module bundlers. For me it works now, can someone verify this? Require jspdf with commonjs like this var jsPDF = require('jspdf'); and with amd something like this requirejs(['libs/jspdf'], function(jsPDF) { ... }.

Until a new version is released you have to clone the repository and build the library manually with npm run build to get the updated dist files.

Try to replace version number with link to the repository in your package.json …i don’t know how it’s possible but working for me 😛

@MrRio Can we please get a hotfix release to fix this?

Ah okey! Yes that is correct. You will have to manually build the dist files until a new version of jspdf is released. The recent changes should fix all issues related to module bundlers such as webpack, browserify and requirejs etc.

Are you looking into releasing a new version soon @MrRio?

Correct, same error about the unexpected token ; for jspdf-autotable. I first saw this by using the compiled library for jsPDF to get around the error in this library, but when I added your plugin, it threw the same error. By the looks of things, error seems to be more related to the reference of the “broken” version of jsPDF in relation to the plugin. From webpack when I try to do a build of my project: Unexpected token: punc (;) [./client/assets/jspdf-autotable/~/jspdf/dist/jspdf.min.js:287,11606]