On Windows 10 or 11, open your Node.js project folder in Visual Studio Code, set a breakpoint beside an executable line, and start debugging with F5. When the app pauses, use the Run and Debug view to inspect variables and the call stack, then step through the code to see how its values change. The steps below use VS Code’s built-in Node.js debugger; no separate debugger extension is required.

A desktop monitor shows JavaScript code paused at a breakpoint in a debugger, with a keyboard and coffee on the desk. Before you start​

You need the following:

  • 64-bit VS Code and Node.js installed on Windows. VS Code’s debugger does not install the Node.js runtime. Choose a Node.js version compatible with your project.
  • A project you trust. Debugging runs the application, including any code that reads or changes files, databases, or services. Use test data and a development environment where possible.
  • The project’s normal setup. If it needs dependencies, environment variables, or a build, follow its instructions first. The practice example below needs none of these.
  • A known way to start the app. A single .js entry file can often be launched directly. An app normally started through an npm script may need the JavaScript Debug Terminal described below.

The VS Code interface and keyboard shortcuts in this guide are the same on Windows 10 and Windows 11. Microsoft ended ordinary support for Windows 10 Home and Pro on October 14, 2025; Extended Security Updates and some LTSC editions have different arrangements. VS Code’s download page lists 64-bit Windows 10 and 11, while its requirements page limits product support to supported Windows client versions.

Open the project and check Node.js​

  1. Start Visual Studio Code and select File > Open Folder. Choose the folder containing your project and select Select Folder. Its files should appear in the Explorer.
  2. Review the project before trusting it. If VS Code opens the folder in Restricted Mode, use the banner or the Restricted Mode status-bar item to open Workspace Trust. Trust the folder only if you trust its contents and authors. Debugging is disabled in Restricted Mode, and trusting a folder can allow project-related code to run.
    To undo that trust decision later, press Ctrl+Shift+P, run Workspaces: Manage Workspace Trust, and select Don’t Trust. If trust is inherited from a parent folder, review the trusted folders list in that editor.
  3. Select Terminal > New Terminal. Enter:
    node --version
    A version number confirms that Node.js is available to that terminal. If Node.js was just installed and the command is not found, close and reopen VS Code, open a new terminal, and try again.
  4. Open the JavaScript file you want to investigate from Explorer. For an existing project, identify the actual entry point or the command you normally use to start it; the file containing the suspicious function is not necessarily the file that starts the app.

If you would rather practice before debugging your own application, create a new empty folder and open it in VS Code. Create a file named app.js, enter the following, and save it with Ctrl+S:

Code:
function calculateTotal(price, quantity) {
  const total = price + quantity;
  return total;
}

const price = 10;
const quantity = 3;
const total = calculateTotal(price, quantity);
console.log(`Total: ${total}`);

This small program is meant to calculate the price of three items at 10 each. The intended result is 30, but the calculation deliberately contains an error.

Set a breakpoint and start debugging​

  1. In app.js, click the margin immediately to the left of the line number for:
    const total = price + quantity;
    A red circle marks the breakpoint. You can also put the cursor on the line and press F9. For your own app, choose an executable line in the code path you want to investigate.
  2. Make sure app.js is the active editor tab. Select Run > Start Debugging, or press F5. If VS Code asks which debugger to use, select Node.js.
    For this simple file, VS Code can start the active file without a launch.json configuration. If your workspace already has a debug configuration, check which configuration is selected in the Run and Debug view: it may start a different file.
  3. Open Run and Debug with Ctrl+Shift+D if it is not already visible. Execution should pause on the calculation line. The highlighted line is the next line to run; the assignment to total has not happened yet.
  4. In VARIABLES, expand Local. In the practice example, price should be 10 and quantity should be 3. You can also hover over those names in the editor to inspect them.

A breakpoint inside a function only pauses when the app calls that function. In a server application, starting the server may not be enough: you may need to make the request or perform the action that reaches the line.

Step through the calculation and inspect values​

While the app is paused, use the debug toolbar to control execution:

  1. Select Step Over, or press F10. VS Code runs the highlighted calculation without stepping into any function calls on that line, then pauses at return total;.
  2. Inspect total under VARIABLES or hover over it in the editor. It is 13, because the program added 10 and 3.
  3. Select View > Debug Console. Enter this expression and press Enter:
    price * quantity
    The result is 30. This expression tests the multiplication using values in the selected stack frame; it does not change the source file. Avoid entering expressions that call functions or change values unless you intend those effects.
  4. Look at CALL STACK in the Run and Debug view. The current function appears there along with its caller. Selecting another frame changes the context used for inspecting variables and evaluating expressions.
  5. Select Continue, or press F5, to let the program finish. The original example prints Total: 13. Once the process exits, its local variables are no longer available to inspect.

Other useful controls are Step Into (F11), which follows a function call on the current line, and Step Out (Shift+F11), which finishes the current function and pauses in its caller. Stop (Shift+F5) ends the current debugging session. On keyboards that reserve function keys for hardware controls, you may need the Fn key.

To track an expression across pauses, select + in the WATCH section and enter the expression. WATCH is useful when a value changes over several calls; remember that an expression can only be evaluated when its variables are available in the selected frame.

Fix and verify the example​

  1. In app.js, replace the faulty calculation with:
    const total = price * quantity;
  2. Save the file. Leave the breakpoint on that line and press F5 to start a new debugging session.
  3. When execution pauses, press F10 once. Confirm that total is now 30 in VARIABLES.
  4. Press F5 to finish. As an additional check outside the debugger, enter the following in the integrated terminal:
    node app.js
    The output should be:
    Total: 30
  5. Click the red breakpoint circle to remove it when you are finished. For a real project, also repeat the action or test that originally exposed the problem; a changed variable alone does not establish that the full workflow is fixed.

Debug an app started through npm​

If your application normally starts through an npm script, running an individual source file with F5 may omit the project’s usual startup behavior. VS Code’s JavaScript Debug Terminal is an alternative that can debug Node.js processes launched in that terminal.

  1. Review the project’s startup script before running it. Scripts can execute arbitrary commands, and the application may connect to real services or modify data.
  2. Set a breakpoint in the Node.js code you want to investigate.
  3. Press Ctrl+Shift+P, type Debug: Create JavaScript Debug Terminal, and select that command.
  4. In the new debug terminal, run the project’s documented start command. For example, use npm run dev only if the project defines and normally uses a dev script.
  5. Trigger the relevant app behavior. When execution reaches the breakpoint, inspect variables and step through the code as above.

The terminal is for shell commands and program input; the Debug Console is where you inspect debugger output and evaluate expressions while paused. If the command starts a server, stop it when finished using the project’s usual terminal controls. Stopping a debugger connection does not necessarily stop a separate process manager.

Use a saved entry point when F5 starts the wrong file​

A launch configuration is useful when the correct Node.js entry point is different from the file you are inspecting, or when you need a repeatable setup.

  1. Open the project folder and press Ctrl+Shift+D.
  2. Select create a launch.json file, then select Node.js. VS Code creates a configuration in .vscode/launch.json.
  3. Check the generated program value. For an application whose entry point is app.js in the opened folder, a basic configuration can look like this:
    Code:
    {
      "version": "0.2.0",
      "configurations": [
        {
          "type": "node",
          "request": "launch",
          "name": "Launch Program",
          "skipFiles": ["<node_internals>/**"],
          "program": "${workspaceFolder}/app.js"
        }
      ]
    }
    Change the path only to your project’s actual entry point. Do not replace an existing launch.json without reviewing it; it may contain configurations your project already uses.
  4. Save the file. In Run and Debug, select Launch Program from the configuration dropdown, set a breakpoint, and press F5.

This launches the file directly. It is not necessarily equivalent to an npm script that supplies arguments, environment variables, or other startup steps. Use the project’s documented command in a JavaScript Debug Terminal when that is the appropriate startup method.

Troubleshoot breakpoints and startup​

  • node is not recognized. Confirm Node.js is installed, restart VS Code, and retry node --version in a new terminal. If it still fails, check the Node.js installation and your project’s required runtime before attempting to debug.
  • The program runs without pausing. Confirm that you used Start Debugging, not Run Without Debugging. Check that the breakpoint is enabled, is on executable code, and that your test actually reaches it. For the practice file, confirm app.js is active and the breakpoint is on the calculation inside calculateTotal.
  • The breakpoint is a hollow gray circle. Hover over it for the debugger’s explanation. Save the file and check that it corresponds to the code actually running. If the project compiles TypeScript or other source into JavaScript, missing or incorrect source maps can prevent the debugger from binding the breakpoint. Build with the project’s source-map settings enabled, then use Debug: Diagnose Breakpoint Problems from the Command Palette while debugging.
  • The wrong app or file starts. Check the selected Run and Debug configuration and its program path. If the project normally starts through an npm script, try its documented command in a JavaScript Debug Terminal rather than launching a source file directly.
  • A variable is missing or the Debug Console cannot find it. Make sure execution is paused inside the relevant function and select its frame in CALL STACK. A variable may not yet have been assigned on the highlighted line. If the process has exited, start the session again.
  • The debugger starts, but the app exits with an error. Read the Debug Console or terminal output for the actual error. Check the project’s required Node.js version, dependencies, environment, and startup command; debugging does not supply missing application setup.
  • VS Code prompts for trust. If you cannot verify the project, leave it in Restricted Mode and do not run it. Review the code and project configuration before granting trust or ask the project maintainer for a verified copy.