Debugging Configuration in VS Code
You'll learn how to set up VS Code to debug JavaScript code running in a browser, using breakpoints right inside your editor instead of juggling browser dev tools.
What This Means
Debugging configuration in VS Code lets you run your web application and pause execution at specific lines using breakpoints—just like you would in browser DevTools, but without leaving your editor. The secret lies in a file called launch.json, which tells VS Code how to start your app and connect the debugger.
Think of it like setting up a direct phone line between your code editor and the browser. Instead of opening Chrome, finding the Sources tab, and navigating to your file, you click next to a line number in VS Code, press F5, and boom—the browser opens and stops exactly where you want it.
How launch.json Works
When you create a debug configuration, VS Code generates a launch.json file inside a .vscode folder in your project. This file contains instructions like:
- What type of debugger to use (
chrome,edge,firefox) - What URL to open (like
http://localhost:3000) - Where your source files live
- Whether to use a development server
For a basic web project, your configuration might specify that VS Code should launch Chrome, navigate to your local server, and map your source files so breakpoints work correctly. Once configured, you can click the gutter beside any line to set a breakpoint, then start debugging with the Run and Debug panel.
Why This Matters
Instead of context-switching between editor and browser, you debug where you code. You see variables, call stacks, and can step through code all in one place—massively improving your workflow, especially when hunting down tricky bugs.
Key Takeaway: Setting up launch.json connects VS Code's debugger to your browser, letting you use breakpoints and inspect code execution without leaving your editor.