VS Code Debugging and Tasks

Launch configurations, breakpoints, tasks.json, and common debugging workflows in VS Code.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Breakpoints and Debug Control
Toggle breakpoint
F9

# Set or remove a breakpoint.

Step over
F10

# Execute current line without stepping into functions.

Step into
F11

# Enter the next function call.

Step out
Shift+F11

# Finish the current function and return to caller.

Continue / pause
F5

# Resume running until next breakpoint.

## launch.json
Basic Node launch config
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Node: Current File",
      "program": "${file}"
    }
  ]
}

# Debug the current Node file.

Attach to existing Node process
{
  "type": "node",
  "request": "attach",
  "name": "Attach 9229",
  "port": 9229
}

# Attach debugger to a process already running with inspect.

Set env vars in launch config
{
  "type": "node",
  "request": "launch",
  "name": "Debug with env",
  "program": "${workspaceFolder}/src/index.js",
  "env": {
    "NODE_ENV": "development",
    "LOG_LEVEL": "debug"
  }
}

# Inject environment variables into debug sessions.

## tasks.json
NPM build task
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "npm: build",
      "type": "shell",
      "command": "npm run build",
      "group": "build"
    }
  ]
}

# Run npm build as a task.

Background watch task
{
  "label": "npm: dev",
  "type": "shell",
  "command": "npm run dev",
  "isBackground": true,
  "problemMatcher": []
}

# Mark long-running watchers as background tasks.

Run build task shortcut
Windows/Linux: Ctrl+Shift+B
macOS: Cmd+Shift+B

# Run default build task quickly.

Recommended next

No recommendations yet.