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

Set or remove a breakpoint.

textANYdebuggingbreakpoint
text
F9

Step over

Execute current line without stepping into functions.

textANYdebugging
text
F10

Step into

Enter the next function call.

textANYdebugging
text
F11

Step out

Finish the current function and return to caller.

textANYdebugging
text
Shift+F11

Continue / pause

Resume running until next breakpoint.

textANYdebugging
text
F5

launch.json

Basic Node launch config

Debug the current Node file.

jsonANYlaunch-jsonnodejs
json
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Node: Current File",
      "program": "${file}"
    }
  ]
}

Attach to existing Node process

Attach debugger to a process already running with inspect.

jsonANYlaunch-jsonnodejsattach
json
{
  "type": "node",
  "request": "attach",
  "name": "Attach 9229",
  "port": 9229
}

Set env vars in launch config

Inject environment variables into debug sessions.

jsonANYlaunch-jsonenv
json
{
  "type": "node",
  "request": "launch",
  "name": "Debug with env",
  "program": "${workspaceFolder}/src/index.js",
  "env": {
    "NODE_ENV": "development",
    "LOG_LEVEL": "debug"
  }
}

tasks.json

NPM build task

Run npm build as a task.

jsonANYtasksnpmbuild
json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "npm: build",
      "type": "shell",
      "command": "npm run build",
      "group": "build"
    }
  ]
}

Background watch task

Mark long-running watchers as background tasks.

jsonANYtaskswatch
json
{
  "label": "npm: dev",
  "type": "shell",
  "command": "npm run dev",
  "isBackground": true,
  "problemMatcher": []
}

Run build task shortcut

Run default build task quickly.

textANYtasksbuild
text
Windows/Linux: Ctrl+Shift+B
macOS: Cmd+Shift+B

Recommended next

No recommendations yet.