Can I specify Node.js command line options in AWS Lambda?
Asked Answered
G

1

13

I'm using AWS SAM and running against Node 10.x.

Would love to pass in the flags for experimental modules and top level await.

Thanks!

Gastrocnemius answered 28/6, 2019 at 17:59 Comment(1)
I am interested in this too now. AWS Lambda is getting more proactive at supporting the latest versions of Node.js and being able to use "Harmony" flags at some point would be useful. Especially with Optional Chaining and Nullish Coalescing now supported Node 13 and Node 14 with --harmony-optional-chaining and --harmony-nullish.Seaward
M
6

You can add Node.js command line options to lambda by setting the NODE_OPTIONS environment variable.

https://nodejs.org/api/cli.html#cli_node_options_options

Mindimindless answered 29/5, 2020 at 5:21 Comment(1)
I tried doing this in template.yaml file, It didn't work for me. Type: AWS::Serverless::Function Properties: CodeUri: functions/stock-checker/ Handler: app.lambdaHandler Runtime: nodejs12.x Environment: Variables: NODE_OPTIONS: "--experimental-modules"Cyanic

© 2022 - 2024 — McMap. All rights reserved.