launch.json lives in .vscode and defines every entry in the Run and Debug dropdown. Two request types cover most cases.
launch: start a program
{
"type": "node",
"request": "launch",
"name": "Launch Server",
"program": "${workspaceFolder}/src/index.js",
"env": { "NODE_ENV": "development" }
}
Use variables like ${workspaceFolder} and ${file} instead of absolute paths so the config is portable.
attach: connect to a running process
{ "type": "node", "request": "attach", "name": "Attach to Process", "port": 9229 }
Great for a server you already started with --inspect.
Build first with preLaunchTask
Point preLaunchTask at a tasks.json label and VS Code builds before it launches:
"preLaunchTask": "build"
Debug the whole stack with compounds
compounds starts several configurations at once — frontend and backend under one click:
"compounds": [
{ "name": "Full Stack", "configurations": ["Launch Server", "Attach to Process"] }
]
Security notes
- Do not hardcode secrets in
env; useenvFilepointing at a git-ignored.env. - Avoid committing configs that attach to production hosts or ports.
Open the launch.json template and ask the workspace to "add a configuration to debug Jest tests" or "add a Chrome launch config for the frontend", then diff the result.