Open gnestor opened 3 years ago
If I prepend by the command with DEBUGGER_ARGS
, I'm able to work around this:
DEBUGGER_ARGS='--experimental-loader /var/task/https-loader.mjs' sam local invoke --env-vars .env.json --debug-port 5858
Thanks for feedback @gnestor, just to confirm this is working with sam local invoke
but it is not working when debugging is enabled, right?
If that is the case then we need to append to the NODE_OPTIONS
environment variable when we are setting up the debugger options.
@mndeveci Correct
Hello same issue, node options are override and does not work when use with debugger for local invoke or start-api. I was not able to override node options with tsconfig-paths/register until @gnestor workaround (thank you btw) Please fix this issue when you can or modify the doc to add parameters in DEBUGGER_ARGS
Description:
If I run a Lambda locally using aws-sam (
sam local start-lambda --env-vars .env.json --debug-port 5858
), theNODE_OPTIONS
that I define in the environment variables are not available. I'm trying to pass--experimental-loader /var/task/https-loader.mjs
specifically, and it works when invoking the Lambda without debugging enabled, but when I invoke with a debugger, the value ofprocess.env.NODE_OPTIONS
is--require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js"
(I'm using the debugger in VS Code). I tried adding"env": { "NODE_OPTIONS": "--experimental-loader /var/task/https-loader.mjs" }
to the VS Code debugger configuration, and the value ofprocess.env.NODE_OPTIONS
is--require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" --experimental-loader /var/task/https-loader.mjs
, but the experimental loader feature is not enabled.I suspect that it's because the user's
NODE_OPTIONS
are being passed through to thenode
executable: https://github.com/aws/aws-sam-cli/blob/59f2d194b65360d5bdeb0b930ff4f8e6dbc7c809/samcli/local/docker/lambda_debug_settings.py#L141Steps to reproduce:
template.yml
functions.https-loader.mjs
functions/index.js
Observed result:
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.30.0Add --debug flag to command you are running