I’m working with the parse-server-mailgun npm package and running into a problem. When I execute the command node ./src/mailgun-test I get this 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 not sure what’s causing this syntax error. Has anyone encountered this before or know how to fix it?
for sure, that seems like a node version issue. i had the same problem & upgrading node did the trick for me. parse-server-mailgun needs ES6 classes, which older versions can’t handle unless strict mode is on. just go for node 8+ and it’ll work!
hey, if you’re stuck, try adding ‘use strict’; at the top of your file. it makes classes work in older node versions. but honestly, updating your node is the way to go to prevent future problems.
It appears you are using an older version of Node.js that does not support ES6 features, including classes, unless strict mode is enabled. The parse-server-mailgun package specifically requires Node 6.0 or higher. I experienced a similar issue when I tried to use newer packages with Node 4.x and resolved it by upgrading to Node 8. You can verify your Node version by running node --version. While adding ‘use strict’; at the top of your script could temporarily fix the issue, upgrading your Node.js version is recommended since many modern packages rely on more recent JavaScript features.
Yeah, it’s definitely a Node version issue, but there’s something else to check. I ran into this exact error on a project where dev and prod had different Node versions. Upgrading Node fixes the syntax problem, but you might be running the test file directly instead of importing the module correctly. That ./src/mailgun-test path looks like you’re executing a test file that wasn’t meant to run standalone. Try importing the main module instead. Also, some older parse-server-mailgun versions had packaging bugs that caused this even with the right Node version.
This syntax error indicates that your Node.js environment does not support ES6 class syntax. I faced a similar situation last year while integrating a mail service; it turns out the parse-server-mailgun library relies on modern JavaScript features that earlier Node versions are unable to utilize. To resolve this, start by checking your Node version using node -v. If it shows a version lower than 6, an upgrade is necessary. Although Node 6 may allow for some ES6 functionality, ensuring you’re on Node 8 or higher is advisable, as many packages, including this one, are designed with compatibility for the more recent versions.
Hit this exact problem during a prod deployment on Node 5.12. The issue is that parse-server-mailgun uses ES6 classes, which need strict mode or Node 6+. What’s annoying is the package.json doesn’t warn you about Node version requirements when installing. I tried the ‘use strict’ fix first but it broke other dependencies. Ended up upgrading to Node 8.11 LTS - fixed the error and boosted performance. Just heads up: test everything after upgrading since newer Node versions can break legacy dependencies in weird ways.
You’ve got a Node version compatibility nightmare. Been there with email services and legacy systems.
Sure, upgrading Node fixes this, but there’s a better way that cuts out dependency hell completely. Ditch parse-server-mailgun and its version drama - build a simple automation workflow instead.
I hit the same wall with different Node versions across our system. An automated email workflow solved everything. Connect Mailgun through webhooks or API calls without any package dependencies.
The workflow handles email sending, tracking, even complex sequences. No ES6 headaches or Node version juggling. Better monitoring and error handling than most npm packages too.
Saved me tons of debugging time on package conflicts. Check it out: https://latenode.com