NPM nullish coalescing not working aka Unexpected token?

Viewed 273

I have a nodejs API server and am using the nullish coalescing opperater.

That worked great for me so far, however since today I am getting the error message

      newsletter: req.body.newsletter ?? false
                                       ^

SyntaxError: Unexpected token ?

I thought maybe there is an issue with some code before that so I replaced it with the oldfashioned

newsletter: req.body.newsletter ? req.body.newsletter : false

Which worked and the error message moved on to the next instance of the use of ??

I am kind of lost what is happening here, I didn't really change anything and the error seems to only happen on my dev machine as the production environment still works fine.

I already tried updating node / npm and reinstalled my node_modules without any luck.

0 Answers
Related