When VS Code's JS debugger refuses to pick up the environment variables your app reads via dotenv, the instinct is to wedge -r dotenv/config into the launch command. That works, but it's the wrong lever — VS Code already has a first-class hook for this, and it's a single line in launch.json.
The full post shows the minimal Node launch configuration with the envFile attribute pointing at ${workspaceFolder}/.env, why this beats the -r dotenv/config workaround, and links the upstream PR I opened against the VS Code docs to make this discoverable next to the more common launch examples.
Originally published at andreasbergstrom.dev — read the full post there.
Top comments (3)
Thanks
Hope this still works!