Node-jsonwebtoken: Upgrading to 6.x throws SyntaxError

Created on 27 Apr 2016  路  10Comments  路  Source: auth0/node-jsonwebtoken

const Hoek = require('hoek');
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/brianknorr/Dev/rd-express-server/node_modules/jsonwebtoken/sign.js:1:73)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

We are using node 0.12.9

Thanks,

Brian

All 10 comments

Plus 1. Having the same issue.

Same problem here, we downgraded to 5.7.0.

This is actually an issue with the package dependencies. I have removed the folder (_sudo rm -R jsonwebtoken_) from my node_modules and installed the previous stable version of this package - (_sudo npm install [email protected]_).

This works for me !!

Also change the same version in your _package.json_ file, if you used '*' for _jsonwebtoken_ module.

@amrendraw3 Going back to a previous version is a workaround, not a solution to the issue. You are right in that, for most, the issue is caused by having jsonwebtoken: '*' in package.json (as in our case) but the actual issue lies in version 6.1.0. It might be intentional but in that case the issue has to be resolved as such.

PS. 5.7.0 was the last stable version prior to 6.*

Thanks for pointing this out, we can try to find out a solution. This is not something in my code but in a dependency that I added: Joi.

However I don't know how long should I keep maintaining modules for node.js versions prior to v4, since v4 is the LTS and current stable version. In this case I don't see any other solution than implementing what I did with Joi in this package.

@jfromaniello I think it's fine if version 6.* breaks compatibility with earlier node versions. It's a major update so there is no requirement to be backwards compatible.
It would be good to point this out in the documentation though, and a note about what kind of patches will be done do the 5.7 branch if any (security fixes would be nice, at least for a while).

Ya I agree...just document the compatibility and provide some sort of support for 5.7. Or see if there is an older version of Joi that works with node 0.12.x and above :)

@jfromaniello at a minimum you should include the node version dependancy in your package.json like joi does.

"engines": {
    "node": ">=4.0.0"
  },

It would also be nice to have a change log and some sort of warning to users that node < 4 is not supported.

Also 0.12 is considered LTS and will be supported until next year https://github.com/nodejs/LTS

You could use an older version of joi that supports node < 4. For now all of us need to use an old version of this library.

Fixed in v6.1.2 (I am using an older version of joi now).

Awesome thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glowlabs picture glowlabs  路  3Comments

ehartford picture ehartford  路  3Comments

shea256 picture shea256  路  3Comments

yvele picture yvele  路  4Comments

prevostc picture prevostc  路  4Comments