I'm getting syntax errors with optional chaining while running an Azure function locally. Using Azure Functions Core Tools 4.0.3971 & Node 14.18.3:
Worker was unable to load function foo: 'SyntaxError: Invalid or unexpected token'
It points to the dot in the optional chaining code as if the syntax is not supported:
variable?.prop
I have Node 14.18.3 installed on my machine, which I understand should support this. Wondering if there is something I could be missing in terms of telling the Azure function to use that Node version?
I would say is a syntax error in your code. I believe this happened to me before, and it is nothing on AFCT nor the AF configuration.
I believe it happened that I did a require wrongly or something along those lines.
Perhaps running eslint on it will help.
This turned out to be another module (CJS) causing the syntax error when trying to include the optional chaining.