Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created February 17, 2026 01:23
Show Gist options
  • Select an option

  • Save Shilo/9c24129a619344542ef9add15868118e to your computer and use it in GitHub Desktop.

Select an option

Save Shilo/9c24129a619344542ef9add15868118e to your computer and use it in GitHub Desktop.
VS Code: Run launch.json configs without the debugger toolbar — workaround using background tasks + instant-exit node to keep commands in the launch dropdown without attaching a debugger

VS Code: Run Launch Configs Without the Debugger Toolbar

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.

How It Works

  1. A shell task runs your actual command — since tasks use "type": "shell", no debugger is involved
  2. The task is marked as "isBackground": true with "activeOnStart": true, so VS Code doesn't block with a "Waiting for preLaunchTask..." prompt
  3. A launch config references the task via preLaunchTask, then runs node -e "" (empty script) — node exits immediately, and the debugger toolbar disappears

Setup

1. Add a shell task in .vscode/tasks.json

{
    "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"
            }
        }
    ]
}

2. Add a launch config in .vscode/launch.json

{
    "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.

Why This Works

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

Tips

  • 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 use pause, add a --no-pause flag 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
@SpechtacularDave

Copy link
Copy Markdown

This is awesome, thank you! I'm surprised this isn't more popular yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment