Skip to main content
⚑ OpenDevDocs
Developer ToolsVS Code
toolsvscodeGuideIntermediate

VS Code: Interactive Debugging & launch.json

Complete guide to VS Code debugging, breakpoints, conditional breakpoints, logpoints, watch variables, call stack inspection, and launch.json configurations.

Verified: 2026-09-30
Tested on:vscode 1.93.x, node 22.x
Platforms:
linuxmacoswindows
#vscode#debugging#nodejs#nextjs#breakpoints

VS Code features an interactive debugger for Node.js, Next.js, TypeScript, Python, and browser runtimes, replacing console.log debugging with step execution, heap inspection, and live expression watches.


Debugging Workflow

  1. Set Breakpoint: Click the left gutter next to any line number (red dot appears).
  2. Launch Session: Press F5 to start debugging.
  3. Inspect Execution State:
    • Variables: Inspect local and global closure scopes.
    • Watch: Add custom expressions to evaluate on every step (e.g. req.headers.authorization).
    • Call Stack: Trace the execution path through parent callers.
    • Debug Console: Interactive REPL in the context of the current paused frame.

Debug Actions Toolbar

Icon / KeyActionDescription
F5ContinueResumes execution until the next breakpoint
F10Step OverExecutes the current line and pauses at the next line
F11Step IntoEnters inside the function called on the current line
Shift + F11Step OutFinishes current function and returns to caller
Cmd/Ctrl + Shift + F5RestartRestarts the debug session
Shift + F5StopTerminates the debugger

Configuring .vscode/launch.json

Create .vscode/launch.json to define repeatable debug configurations:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Next.js App Router (Full Stack)",
      "type": "node-terminal",
      "request": "launch",
      "command": "npm run dev"
    },
    {
      "name": "Debug Current TypeScript File (tsx)",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "tsx",
      "args": ["${file}"],
      "internalConsoleOptions": "openOnSessionStart",
      "skipFiles": ["<node_internals>/**", "**/node_modules/**"]
    },
    {
      "name": "Attach to Running Node Process",
      "type": "node",
      "request": "attach",
      "port": 9229,
      "restart": true
    }
  ]
}

Conditional Breakpoints & Logpoints

Right-click the gutter next to a line number:

  • Add Conditional Breakpoint: Triggers only when a condition matches (e.g. items.length === 0).
  • Add Logpoint: Prints a message to Debug Console without halting execution (e.g. User logged in with ID: {user.id}).

On this page