VS Code's launch.json only supports debug-type configurations ("type": "node", etc.), which always attach a debugger toolbar — even for simple shell scripts or build tasks. There's no built-in way to run a command from the launch dropdown without it.
This workaround combines a background shell task (no debugger) with a minimal launch config that exits instantly, causing the debugger to detach.
- A shell task runs your actual command — since tasks use
"type": "shell", no debugger is involved - The task is marked as
"isBackground": truewith"activeOnStart": true, so VS Code doesn't block with a "Waiting for preLaunchTask..." prompt - A launch config references the task via
preLaunchTask, then runsnode -e ""(empty script) — node exits immediately, and the debugger toolbar disappears
{
"version": "2.0.0",
"tasks": [
{
"label": "My Command",
"type": "shell",
"command": "your-command-here",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "^$"
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "^$never$"
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared"
}
}
]
}{
"version": "0.2.0",
"configurations": [
{
"name": "My Command",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["-e", ""],
"preLaunchTask": "My Command",
"cwd": "${workspaceFolder}"
}
]
}The "label" in the task must match the "preLaunchTask" in the launch config.
| Part | Role |
|---|---|
"isBackground": true |
Tells VS Code the task is long-running and shouldn't be waited on |
"activeOnStart": true |
Marks the task as active immediately, so the launch config proceeds without blocking |
"endsPattern": "^$never$" |
A pattern that never matches — prevents VS Code from thinking the task ended prematurely |
node -e "" |
Runs an empty Node.js script that exits instantly, causing the debugger to detach |
- Windows batch files: Use
"command": "cmd"with"args": ["/c", "your-script.bat"] - Multiple commands: Chain with
call:"args": ["/c", "call build.bat && call deploy.bat"] - Avoid
pause: If your scripts usepause, add a--no-pauseflag for automated usage, since there's no interactive input in background tasks - The task stays visible in the integrated terminal — you still see all output
- The launch entry appears in the normal Run/Debug dropdown (F5) like any other config