Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to How To Guides
How to Debug Code in VS Code

How to Debug Code in VS Code

How To Guides2,867 viewsBy Admin
how-todebugcode

Advertisement

Debugging in VS Code

VS Code has a powerful built-in debugger — far better than scattering console.log everywhere. Here's how to use it.

Step 1: Set a Breakpoint

Click in the gutter (left of line numbers). A red dot appears — execution will pause there.

Step 2: Start Debugging

Press F5, or click Run → Start Debugging
# For Node.js, select "Node.js" environment

Step 3: Control Execution

ActionKey
ContinueF5
Step OverF10
Step IntoF11
StopShift + F5

Step 4: Inspect Variables

When paused, hover over variables to see values, or check the Variables panel on the left.

launch.json for Custom Setups

{
  "version": "0.2.0",
  "configurations": [{
    "type": "node",
    "request": "launch",
    "name": "Debug App",
    "program": "${workspaceFolder}/index.js"
  }]
}

FAQs

Debugger or console.log?

The debugger lets you inspect everything at any point without editing code. More in our how-to guides.

Can I debug in the browser?

Yes — with the JavaScript Debugger for Chrome/Edge.

Advertisement