dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

env variables not passed into serverless-offline while debugging with visual studio #1773

Open robertlario opened 3 months ago

robertlario commented 3 months ago

Bug Report

Current Behavior env set in launch.json are not set in process.env.

Sample Code file: launch.json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 //"program": "${workspaceFolder}/node_modules/serverless/bin/serverless", "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${userHome}/AppData/Roaming/npm/node_modules/serverless/bin/serverless", "args": [ "offline", "start", "--httpPort", "4000", "--noTimeout", ], "runtimeExecutable": "node", "runtimeArgs": [ "--preserve-symlinks-main", "--preserve-symlinks" ], "stopOnEntry": true, "env": {"MYVAR": "value"} } ] }

Sample Code file: handler.js module.exports.hello = async (event) => { const { MYVAR} = process.env; return { statusCode: 200, body: JSON.stringify('Hello ' + robert ) }; };

Sample Code file: serverless.yml service: roberts

frameworkVersion: '3'

provider: name: aws runtime: nodejs18.x

plugins:

functions: hello: handler: handler.hello events: