Jspdf: Uncaught SyntaxError: Unexpected token ;

Created on 2 Feb 2016  路  28Comments  路  Source: MrRio/jsPDF

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 ;

Most helpful comment

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.

All 28 comments

+1
import jsPDF from 'jspdf';

Hi there,

Thanks for you issue. Can you try again with the latest release and reopen if it's still happening?

Many thanks,
James

Hey, I used latest (1.2.60) version, and I also have same error!

Is this just a webpack thing? What's the quickest way for me to reproduce?

What does jspdf.debug.js say?

I don't know how to access jspdf.debug from node modules since dist folder contain only jspdf.min.js

Update: I've created demo file require('jspdf'); but this time I'm using browserify, and it requires properly. So the problem should be webpack

It looks similar to this problem (also webpack, but with json-loader):

https://github.com/webpack/json-loader/issues/13

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.

@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';

@simonbengtsson Looks like your autotable library is suffering from the same issue.

Do you experience the Uncaught SyntaxError: Unexpected token; for jspdf-autotable? What code are you using?

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]

Hmm strange. Can you post an issue on jpsdf-autotable with the webpack config that I can use to replicate it?

You did confirm that this issue is solved for jspdf with the latest updates on the master branch right?

Correct, the issue for jspdf was resolved by cloning and rebuilding. I'll try to get an issue put in today....but it might be as simple as either pointing the package.json for autotable to jspdf master, or getting jsPDF released with the fix so autotable can be updated to use the fix as well :)

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?

@simonbengtsson Thank you for your work!

@simonbengtsson I still got the same error after cloning and rebuilding, is something with my webpack config?

i got the same error

@lvbeck Probably, can you test using a scaled down version of your config? I got it to work with a very basic one at least.

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

@MrRio just a kindly ping.

I've rebuilt the lib, works fine with webpack now. https://github.com/MrRio/jsPDF/pull/774,

@simonbengtsson latest master is also broken.

also having this problem, tried version 1.2.60 and 1.2.61.

same here getting Unexpected toekn ; at line 237 of jspdf.min.js running 1.2.61 with webpack 1.13.1.
("undefined"==typeof require_baseUrl_override&&(require_baseUrl_override="../"),;
guess it's the extra ';' at the end

Update: replaced jspdf.min.js with jspdf.debug.js. it works with jspdf debug

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 :P

That would work because it points to master, instead of a specific tag.

This is now fixed in 1.3.x 馃憤 https://github.com/MrRio/jsPDF/issues/506

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arulmb0136 picture arulmb0136  路  4Comments

baluMallisetty picture baluMallisetty  路  4Comments

mackersD picture mackersD  路  4Comments

mellisa0109 picture mellisa0109  路  3Comments

andmaltes picture andmaltes  路  4Comments