I’m having trouble setting up the mailgun adapter for my parse server project. Every time I try to run the test file with node ./src/mailgun-test, I keep getting this weird syntax error:
.../node_modules/parse-server-mailgun/src/mailgun-test/index.js:28
Account: class Account {
^^^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
I’m following the documentation but can’t figure out what’s causing this issue. Has anyone encountered this before? I’m not sure if it’s a version compatibility problem or something else entirely.
Had this exact same error with parse-server-mailgun on an older production setup. The problem is that the package uses ES6 class syntax, which needs strict mode on Node versions before 6.0. You can add ‘use strict’; to your files as a quick fix, but it’s a pain when you’ve got multiple dependencies. Best solution is upgrading to Node 8.x or higher - it handles ES6 natively without needing strict mode. If you can’t upgrade right away because of deployment issues, try using nvm to test locally with a newer version first.
This is a Node.js version compatibility issue. Your Node.js version doesn’t support ES6 classes outside strict mode, and the parse-server-mailgun package needs a newer version with full ES6 support. I hit the same problem with an older Node.js on a legacy server. Check your version with node --version and upgrade to at least 6.x, though I’d go with the latest LTS for better compatibility. You could add ‘use strict’; at the top of your test file as a quick fix, but upgrading Node.js is the real solution.
yep, it’s your node version for sure. those es6 classes need strict mode. check your version with node -v, if it’s below v6, just upgrade it. adding ‘use strict’; in your file helps, but upgrading is the way to go in the long run.