Home
Support Forums

Issue with Netlify functions

Hello,

We are encountering an issue only on Netlify ( we are testing our function using Node 12 version locally and into our dev environment) with Netlify function at runtime :

Site name: https://dev-lune.netlify.app/.netlify/functions/download?id=31498346

This url is supposed to run a 301 redirection to an existing URL (tested) but we are getting the following error:

"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Unexpected token '.'",
"trace": [
"Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'",
" at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}

Do you have any idea about the reason why we are getting this error ? (Node.js version or our script, …)

Thanks a lot for your feedback.

Best

It’s a syntax error - pretty generic. It’s complaining about a .. I had a theory, but since you say it works finally locally with Node 12, that won’t apply.

So in your case, I think we’d need to see the function code to be able to find the cause of the error.

Hi @hrishikesh

We changed Node.js version to be used in Netlify function to 14 and it works fine now.
Even if we were running Node.js 12 locally, it seems (obviously) related to this.

Thanks for your help.