No BigInt support for Netlify Functions

Netlify Functions do not support BigInt. Getting a syntax error (runs fine in my tests):

“errorMessage”:“Invalid or unexpected token”,“errorType”:“SyntaxError”,

It appears to be choking on the ‘n’ notation, e.g.:

const startConstant = [];
startConstant[1] = 1n;
startConstant[3] = 13n;
startConstant[7] = 37n;
startConstant[9] = 19n;

Remove the ‘n’ and it compiles fine:

const startConstant = [];
startConstant[1] = 1;
startConstant[3] = 13;
startConstant[7] = 37;
startConstant[9] = 19;

BigInt has been supported by Node since v10.4.0, which is in LTS. Is there a way to specify a node version to be executed on the server?

Set the variable AWS_LAMBDA_JS_RUNTIME with the value nodejs10.x

@talves,

Thanks for your help. I do read the documentation, but it’s easy to miss stuff. I tried setting this in the netlify.toml file, but it didn’t seem to work:

[build.environment]
AWS_LAMBDA_JS_RUNTIME = “nodejs10.x”

Could be that’s the wrong place to set it. I was able to set it in the Build & Deploy UI under Environment Variables, and that seemed to do the trick.

2 Likes

Thanks for the clarification. I just tested this out and their assertion is correct. That particular en var only works in the dashboard and not in the netlify.toml. This definitely needs documentation.

1 Like