serverless-offline icon indicating copy to clipboard operation
serverless-offline copied to clipboard

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

Open robertlario opened this issue 10 months ago • 0 comments

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:

  • serverless-offline

functions: hello: handler: handler.hello events: - http: path: /hello method: get cors: true

robertlario avatar Mar 29 '24 21:03 robertlario