0
votes

I found following error when I'm rendering my nodejs project

{"level":"error","message":"uncaughtException SyntaxError: Use of const in strict mode.\n at Module._compile (module.js:439:25)\n at Object.Module._extensions..js (module.js:474:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n at Module.require (module.js:364:17)\n at require (module.js:380:17)\n at Object. (/var/www/myproject/dist/node_modules/sparkpost/node_modules/request/node_modules/hawk/lib/index.js:5:33)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n at Module.require (module.js:364:17)\n at require (module.js:380:17)\n at Object. (/var/www/myproject/dist/node_modules/sparkpost/node_modules/request/request.js:9:12)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)","timestamp":"2017-09-25T02:45:43.418Z"}

That's why I check sparkpost version inside my package.json file and found "sparkpost": "^1.3.7", but when I checked with npm info sparkpost version, it goes 2.1.2

Can something help me any suggestion that how can I check actual version of sparkpost and how can I fix that error message, thanks.

1
It looks like sparkpost does not in fact support very old Node.js versions. Upgrading to at least Node 4.x might be your best solution. I opened a GitHub issue on this too.Ewan Dennis
@EwanDennis can you please tell me how to use Old Node.js needs --harmony to enable const.PPShein
I doubt continuing with Node.js 0.10 will resolve this problem. I strongly recommend you upgrade to at least Node.js v4. The current versions are always linked at https://nodejs.org/en/.Ewan Dennis

1 Answers

2
votes

npm info <package_name> outputs the registry info for the latest version of <package_name> (unless you specify a version). That is, it's not going to describe your local package. npm help info explains all the gory details.

Instead, you can use npm list sparkpost to determine the version of sparkpost you have locally. Or, you can always manually inspect the locally installed version by examining the dependency's package.json with something like cat node_modules/sparkpost/package.json | grep version.

As for the actual error: you need to provide more context. You could get this if you're running a version of node < 4.0.0 without the --harmony flag. Depending on your application's requirements, you could update node or add the harmony flag to try resolving the error. Have a look at: SyntaxError: Use of const in strict mode