Click in the gutter to drop a breakpoint, press F5, pick Node.js if VS Code asks, then walk through the paused code with F10, F11 and Shift+F11. For a single file you don’t need a launch.json or any extension.
The Stack Overflow Developer Survey 2025 has Visual Studio Code as the most used development environment, at 75.9% of respondents. Odds are you already have it open.
A lot of older tutorials still start with installing the Debugger for Chrome extension. Don’t bother. Microsoft deprecated it because js-debug, the debugger bundled with VS Code, already handles Node.js, Chrome and Edge.
How Do You Start Debugging a JavaScript File in VS Code?

Node.js has to be installed, and that’s the whole requirement. A single file needs no existing project, no extra extension, no package and no launch.json configuration.
- Open the folder that holds the file, then run node –version in a VS Code terminal to check that Node.js responds.
- Click the margin left of the line number, or put the cursor on the line and press F9. A red circle marks the breakpoint.
- Go to Run, then Start Debugging (F5), and choose Node.js if you’re prompted.
- Execution pauses on the breakpoint line and the Variables panel lists the local values. On Windows and Linux, Ctrl+Shift+D opens the Run and Debug view.
- Press F10 to step over one line, and use the Debug Console to evaluate expressions. None of that changes the source file.
- Press F5 again to continue. That finishes the program and ends the session.
Microsoft’s own quickstart (page dated 11/18/2026) uses a calculateTotal function that prints 13 when it should print 30. One step in, price is 10 and quantity is 3, and you can see the code adds them where it should multiply.
If all you want is to run the file and not pause anywhere, the guide on running JavaScript in VS Code gets you there quicker than a debug session.
Pass arguments or set environment variables and you’re in launch.json territory. Same for a specific entry point.
Which Debugger Does VS Code Use for JavaScript?
Nothing to install here. VS Code ships with js-debug (vscode-js-debug), and Microsoft says it debugs Node.js, Chrome, Edge, WebView2 and VS Code extensions.
It’s built on the Debug Adapter Protocol, the layer that connects the editor interface to the debugger. In launch.json you choose the type: node for server code, chrome or msedge for browser code (msedge is the documented Edge type). Node.js 8.x and above is supported, according to the Node.js debugging page dated 10/28/2026. The browser debugging page covers Chrome and Edge but names no minimum versions.
Each VS Code release carries whichever js-debug version was current at release time, and a nightly build exists too.
Plenty of older material says otherwise. One community gist still has readers install the Debugger for Chrome extension first, and that extension’s Marketplace page still shows 10,998,156 installs.
That same page marks the extension deprecated and says you can uninstall it safely. Visual Studio Magazine reported back in 2021 that js-debug had been the default since VS Code 1.46.
So if a tutorial opens with installing Debugger for Chrome, it’s dated. Skip that step.
Which Launch Method Fits Your Project?
It comes down to how the process starts. F5 is fine for one file. If you’re typing commands into a terminal anyway, the JavaScript Debug Terminal picks them up, and launch.json is for setups you run again and again. Attach is for processes that were already running before VS Code got involved.
| Method | How it starts | Best for | Documented limit |
|---|---|---|---|
| F5 on the active file | Run and Debug, F5 | One script | No custom arguments or environment variables without launch.json |
| JavaScript Debug Terminal | Command Palette: Create JavaScript Debug Terminal | npm scripts and typed commands | Only processes started inside that terminal |
| Auto attach | Toggle Auto Attach, then restart the terminal | Every Node.js process in the integrated terminal | Terminal restart needed after toggling |
| launch.json | Selected configuration, then F5 | Repeatable team setups | The file needs writing and upkeep |
| Attach | Attach configuration or process picker | A process started outside VS Code | Process must run with –inspect or –inspect-brk, default port 9229 |
The JavaScript Debug Terminal works just like the regular VS Code terminal. The one difference is that any Node.js process you start in it gets debugged automatically.
Auto attach is controlled by the debug.javascript.autoAttachFilter setting. Set it to smart and it debugs scripts run outside node_modules, plus common runners such as mocha or ts-node. The always mode debugs every Node.js process started in the Integrated Terminal, which can get noisy if you run a lot of Node tools there. onlyWithFlag sticks to processes started with –inspect or –inspect-brk.
Properties you’d normally put in launch.json can also go in the debug.javascript.terminalOptions setting. You edit settings.json once, and every debug terminal after that inherits the same skipFiles.
My own rule is simple. Type the same command twice and it’s time for a launch.json.
How Do You Configure launch.json?

The file lives in the .vscode folder of your workspace. Every entry needs a type and a request, plus the file or URL you’re debugging.
VS Code ships starter snippets for Launch Program, Launch via npm, Nodemon Setup and Mocha Tests, and starting from one of those beats writing the file by hand.
Launch and attach requests
With a launch request, VS Code starts the program itself. Pressing Stop sends SIGINT first so the program can shut down gracefully, and a second press force-kills it.
An attach request connects to a Node.js process that’s already running with –inspect or –inspect-brk. Stop only disconnects and leaves the program running. The processId property takes a PID string or ${command:PickProcess}, and setting restart to true reattaches after Node.js terminates.
Attaching gives up after about 10 seconds unless you raise timeout.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch app.js",
"program": "${workspaceFolder}/app.js",
"skipFiles": ["<node_internals>/**"]
}
]
}That <node_internals>/** pattern in skipFiles stops the debugger from stepping into Node’s own modules.
Properties you set most often
| Property | What it takes |
|---|---|
| program | Absolute path to the file to debug |
| args | An array, one argument per element |
| skipFiles | Glob patterns, such as node_modules/**/*.js under the workspace folder |
| runtimeExecutable | The executable to run, default node |
| console | internalConsole by default, or integratedTerminal and externalTerminal |
The console default catches people out. The debug console cannot read input, so a program that prompts the user needs console set to integratedTerminal or externalTerminal.
Which Breakpoint Type Should You Use?
Line breakpoints cover most of it. Inside loops, switch to a conditional or hit count breakpoint. The rest are situational.
A line breakpoint is the plain one. Click the gutter or press F9 and it pauses on that line. Nothing more to it.
For a conditional breakpoint, right-click the gutter and choose Conditional Breakpoint. It pauses only when the expression is truthy. Hit count lives in the same place: choose Conditional Breakpoint, then switch to Hit Count.
Hit count takes either an integer or a comparison.
- >10 breaks after 10 hits
- <3 stops on the first two hits only
- A bare 10 behaves like >=10
- %2 breaks on every other hit
VS Code’s own debugging page says the syntax varies by debugger and doesn’t give examples, so test these forms in a live js-debug session before trusting them.
Logpoints write a message to the Debug Console without pausing. Curly braces interpolate values, as in “current value is: {myVariable.property}”. I reach for them before console.log almost every time, mostly because there’s nothing to clean up afterward.
A triggered breakpoint gets added from the glyph margin, and you pick the breakpoint that activates it.
A debugger statement in your code pauses just like a line breakpoint, only it lives in the source instead of the editor interface. Delete it before you commit.
Exception breakpoints pause on the throwing line, and Chrome’s DevTools documentation describes them as covering caught and uncaught exceptions. VS Code’s own debugging page doesn’t describe them at all, so look in the Breakpoints section of the Run and Debug view during a live session.
VS Code also documents inline breakpoints (Shift+F9, which pause at a column and help in minified code), plus function and data breakpoints. Which types work depends on the debugger extension, so test each one against js-debug before relying on it.
How Do You Step Through Code and Inspect State?
Inspection only works while the program is paused, and you have to select the stack frame you care about first. After that, stepping and the panels do the rest.
Stepping controls
| Control | Shortcut (Windows and Linux) | What it does |
|---|---|---|
| Step Over | F10 | Runs the current line, stays in the current function |
| Step Into | F11 | Enters the function called on the current line |
| Step Out | Shift+F11 | Finishes the current function, returns to the caller |
| Restart | Ctrl+Shift+F5 | Starts the session again |
| Stop | Shift+F5 | Ends the session |
The debug.toolBarLocation setting sets the toolbar to floating, docked or hidden. Available actions vary by debugger.
Variables, Watch and Call Stack
The Variables panel shows local and global values for the selected stack frame. Set Value in the context menu changes one, and Ctrl+Alt+F filters the list.
Watch works differently. Add an expression with the plus button and it gets evaluated every time the debugger pauses.
The Call Stack lists active function calls, and selecting a frame shows its source location and variables. Loaded Scripts is read-only and only viewable during an active session.
Hovering over an expression in the editor shows its current value. Watch out when you hover on the highlighted line, though. A variable assigned there has no new value until that line runs.
Debug Console
Open it with Ctrl+Shift+Y. It evaluates expressions in the context of the selected stack frame, so picking another frame in the Call Stack changes what a name resolves to.
Shift+Enter adds a line in multiline input, and Enter evaluates.
Evaluation support depends on the debugger, and once the program exits you need a new session to inspect state again.
How Do You Debug Node.js Code?

Which route you take depends on who starts the process. If the debugger does, use a launch.json entry or the JavaScript Debug Terminal on the entry file. If something else already did, attach through the inspector. Back-end development in Node.js usually means a server that stays alive, so it matters who started it.
Express and npm scripts
For Express, point program at the file that boots the server and press F5. The Debug Console attaches to the running app, so typing process.env there evaluates inside the live process.
nodemon is a different case. VS Code ships a Nodemon Setup snippet, and Microsoft keeps a nodemon recipe in its vscode-recipes repository.
The documented catch is that nodemon cannot start while the code has syntax errors. Linting in the editor catches those errors before the debug session does.
Attaching to a running process
Start the process with –inspect and it listens on 127.0.0.1:9229 by default. –inspect-brk uses the same address but breaks before user code starts, and –inspect=host:port binds a custom host and port. Then attach through the Attach to Node Process picker or an attach configuration.
The VS Code docs describe attaching to processes started with those flags. The processId attribute is the exception: it sends a SIGUSR1 signal before attaching, so a process that wasn’t started in debug mode can be attached too. Node.js’s own guide documents the same route. A SIGUSR1 signal makes a running process listen for debugging messages, except on Windows.
Be careful with security here. The debugger has full access to the Node.js execution environment, so binding it to a public IP or 0.0.0.0 lets any client that can reach the address connect.
Even on 127.0.0.1, any application running locally has unrestricted access to the inspector.
For a remote host, Node.js documents an SSH tunnel. Running ssh -L 9221:localhost:9229 user@remote.example.com forwards local port 9221 to port 9229 on the remote machine, and VS Code maps paths between the two machines with localRoot and remoteRoot.
How Do You Debug Front-End JavaScript in Chrome or Edge?
A launch.json entry with type chrome or msedge and a url is all it takes. VS Code opens the page and attaches. There’s also an editor-browser type, which debugs inside the integrated browser instead.
Launching a new browser instance
Set url and VS Code opens it automatically. With no server, file debugs a single file directly. runtimeExecutable is stable by default and also takes canary, beta, dev or an absolute path. webRoot defaults to the workspace folder and drives source map resolution.
{
"type": "chrome",
"request": "launch",
"name": "Debug front end",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}The Open Link command picks Edge if that’s your default browser and looks for Chrome otherwise. There’s also an Emulate a focused page option in the Debug Options panel, which keeps the page behaving as focused while VS Code is in the foreground.
Built with React? There’s a separate walkthrough for debugging a React app in VS Code.
Attaching to a running browser
- Start the browser with –remote-debugging-port=9222 and a separate –user-data-dir.
- Add a configuration with request attach, type msedge or chrome, and port 9222. The port must match –remote-debugging-port.
- Start debugging. Without a url, VS Code attaches to all browser tabs, and address reaches a browser on another machine.
Leave out the separate –user-data-dir and the command just opens a new window in the already-running browser, which never enters debug mode.
When Chrome DevTools is the better choice
On the VS Code side you get breakpoints, stepping and the Debug Console right next to your source files, plus a launch.json that teammates can reuse. DevTools covers the Elements panel for viewing and changing the DOM and CSS. Its Network panel is for viewing and debugging network activity, and the Performance panel evaluates page performance.
VS Code’s browser debugging page doesn’t say which DevTools features are missing, so this split is practical, not documented.
Logic bugs in your own source are a VS Code job. If it’s layout, network or rendering, open DevTools.
How Do You Debug TypeScript and Bundled Code With Source Maps?
TypeScript debugging relies on JavaScript source maps, so generate them in the compiler or bundler first. Then point outFiles at the generated JavaScript so js-debug can map breakpoints back to the original files.
In TypeScript, setting sourceMap to true in tsconfig.json (or passing the –sourcemap compiler flag) writes .js.map files next to the output and adds a sourceMappingURL comment to each .js file. inlineSourceMap embeds the map in the .js file instead, and it is mutually exclusive with sourceMap.
With Vite, build.sourcemap defaults to false. True creates a separate file, and inline appends a data URI. The hidden value works like true, with the sourcemap comments suppressed.
webpack’s devtool default is trickier. It’s false, except in development mode, where it becomes eval, and eval maps to the transpiled code, not the original source. The documented choice for development builds with original-source quality is eval-source-map. For production builds it’s source-map.
On the VS Code side, outFiles takes an array of glob patterns that locate the generated JavaScript. The Node.js debugging page lists a few related options too, including sourceMaps (default true), resolveSourceMapLocations, smartStep and sourceMapPathOverrides.
{
"type": "node",
"request": "launch",
"name": "Debug compiled app",
"program": "${workspaceFolder}/src/index.ts",
"outFiles": ["${workspaceFolder}/out/**/*.js"]
}That outFiles path matches the outDir of “out” in the tsconfig.json from VS Code’s TypeScript tutorial.
Haven’t got the project compiling yet? Start with the guide on running TypeScript in VS Code.
One error message points straight at the cause. “Cannot launch program because corresponding JavaScript cannot be found” usually means sourceMap isn’t true in tsconfig.json, or outFiles is missing from launch.json.
smartStep tries to step over code that does not map to source files.
Why Is the Breakpoint Gray or Never Hit?
A gray breakpoint usually means the source map chain is broken somewhere. If it never fires, check how the program was started, or whether the browser ever entered debug mode.
| Symptom | Documented cause | Fix |
|---|---|---|
| Breakpoint stays gray | Source map missing or broken | Have the transpiler generate the maps |
| “Cannot launch program because corresponding JavaScript cannot be found” | sourceMap not true in tsconfig.json, or outFiles missing in launch.json | Set both, then rebuild |
| Breakpoint lands on a different line | Code not yet parsed. VS Code passes –nolazy by default to avoid this. | Keep –nolazy, accept the slower startup |
| Browser opens, breakpoints never bind | No separate –user-data-dir, so the browser opens a window in the running instance | Add –user-data-dir to the browser command |
| Original file never appears | Source map URL unreachable. Load failures appear in the Debug Console. | Read the Debug Console message, fix the map URL |
Windows has its own wrinkle. According to the Node.js debugging page, Stop forcibly kills the debuggee and its child processes there.
That’s different from the SIGINT-first shutdown described for launch requests, so test cleanup logic on the platform you ship to.
When a breakpoint stays gray, check the source map first.
JavaScript Debugging in VS Code FAQ
How do you debug Jest tests in VS Code?
Add a launch.json entry that starts Jest with runtimeArgs of –inspect-brk, the path to the Jest binary and –runInBand, and set console to integratedTerminal. Jest normally runs tests in parallel across processes, and trying to debug several processes at once is a headache.
Can VS Code debug JavaScript running in Firefox?
Not with the built-in debugger, which Microsoft lists as covering Node.js, Chrome, Edge and WebView2. There’s a separate Debugger for Firefox extension, published under the firefox-devtools GitHub organization, that handles web apps and extensions in Firefox. Its attach mode needs Firefox started with the -start-debugger-server flag.
Is Restart Frame the same as restarting the session?
No. Restart Frame goes back to the start of the current function, so you can change a variable with Set Value and rerun that code without ending the session.
It doesn’t roll back anything changed outside the function, though, so results can differ from a fresh run.
Which setup restarts the session when a file changes?
nodemon, the only tool the VS Code docs name for this. You can run nodemon –inspect server.js and attach with restart set to true on port 9229, or launch with runtimeExecutable set to nodemon.
Stop only ends the debug session, so stop nodemon yourself in the integrated terminal.
Where to Start When the Failing Line Is Unknown
Start at the earliest line of the failing path, not the line where the error shows up. From there, narrow forward until a value first goes wrong.
Put a breakpoint on that first line (or use –inspect-brk for a Node.js process). Next, add logpoints at the places you suspect. Once a logged value first goes wrong, drop a conditional or hit count breakpoint right there.
Logpoints come second because a paused process stops running its own code, which shifts timers and network callbacks. The catch is that a logpoint only writes a message to the Debug Console without pausing, so you see just the values you interpolate, and the Variables panel and Call Stack sit idle until the next pause.
This sequence holds as of November 20, 2026, against VS Code documentation pages dated 10/28/2026 and 11/18/2026. Once exception breakpoints are documented for js-debug, they’d go ahead of the first pause.
And if nothing in the current code explains the failure, git bisect will find the commit that introduced it.
- PyCharm Tutorial: From Install to Your First Debug Session - December 3, 2026
- How Software Teams Can Retire Old Hardware Without Losing Sleep - December 2, 2026
- PyCharm vs VS Code for Python: Speed, Debugging, Cost - December 1, 2026



