Problem compiling module

I’m including a module in my project that is throwing an error. It appears to be failing to parse a coalescing operator: options.token = options.token ?? uuid.v4() I’ve tested putting this operator in my code and it works; is there something special about it being included through a module?

Exception:

W20210407-13:41:54.400(-4)? (STDERR) SyntaxError: Unexpected token '?'
W20210407-13:41:54.400(-4)? (STDERR)     at wrapSafe (internal/modules/cjs/loader.js:915:16)
W20210407-13:41:54.400(-4)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:963:27)
1 Like

Can anyone confirm that modules using nullish coalescing operators are properly parsed and compiled?

Nevermind - I see that the issue is meteor is still running on node 12 internally. Hopefully this ticket can be closed soon: Update Meteor to Node.js 14 · Issue #402 · meteor/meteor-feature-requests · GitHub

If this is coming from an NPM package, you can probably fix it by telling meteor to recompile the package.

https://guide.meteor.com/using-npm-packages.html#recompile

No, the problem is the other way. When I do meteor node -v, I see the version bundled is 12.22.1. The npm packages are using syntax that isn’t understood by node until 14, so recompiling won’t help.

It seems that if they were transpiled via babel using Meteor’s recompile feature then they could be used in node 12 :man_shrugging:

1 Like