Today I got stuck trying to figure out why the JS-debugger in Visual Studio Code didn't pick up my environment variables. I use the dotenv-package when running Node outside of its Docker-container, so somehow adding -r dotenv/config
to the command being executed seemed like the obvious solution.
It turns out the correct way is through the envFile
attribute in the task configuration. This is how my task configuration looks now:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"stopOnEntry": false,
"envFile": "${workspaceFolder}/.env",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/app.js"
}
]
}
I thought this should be mentioned with the most common examples in the docs so I created a Pull Request to add this.
Top comments (2)
Thanks
Hope this still works!