Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

VS Code breakpoints stay grey and the Node.js debugger never stops

Your error

Unbound breakpoint3 more lines it can show

Fix it fast

Most common cause, 1 of 4

The build writes no source maps

Turn on sourceMap in tsconfig.json (the Firebase TypeScript template ships with it on) and rebuild so every .js gets a .js.map.

Fix
{
  "compilerOptions": {
    "outDir": "lib",
    "sourceMap": true
  }
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

VS Code 1.147 shows "Unbound breakpoint" when its debugger cannot map the line you clicked to code that is running. With TypeScript, Firebase Functions in lib/ included, check for missing source maps, an outFiles pattern that misses the compiled files, stale build output, or map paths that point elsewhere. Run Debug: Diagnose Breakpoint Problems first.

  • Applies to VS Code 1.147, vscode-js-debug 1.140, TypeScript 7.0, firebase-tools 15.37
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Start the debug session, then open the Command Palette and run Debug: Diagnose Breakpoint Problems. The tool reads what the debugger has loaded and names the gap. In a terminal, also list what the build produced next to the JavaScript.

Run this first
ls lib/*.js lib/*.js.map

Then find the line you see in this list and open its fix:

  1. 1The build writes no source mapsThere is no .js.map file beside the compiled .js and no inline sourceMappingURL comment; the diagnose tool says to set up the build tool to create sourcemaps
  2. 2outFiles in launch.json does not cover the compiled folderMaps exist, but launch.json narrows outFiles to a folder like dist or out while the code really runs from lib (or the other way round)
  3. 3The running JavaScript is older than your TypeScriptBreakpoints bind on some lines but not on code you just wrote, or the diagnose tool says your compiled code might be out of date with your sources
  4. 4The source map points to paths that differ from your folderThe diagnose tool says it found other files with the same name, or the folder was opened with different letter case than on disk

What does the error look like?

  • Unbound breakpoint
  • We couldn't find a corresponding source location, and didn't find any source with the name index.ts.
  • We couldn't find a corresponding source location, but found some other files with the same name:
  • Breakpoint ignored because generated code not found (source map problem?)

Cause 1 of 4

The build writes no source maps

You seeThere is no .js.map file beside the compiled .js and no inline sourceMappingURL comment; the diagnose tool says to set up the build tool to create sourcemaps

Check

An Unbound breakpoint in a .ts file often means nothing links that file to the JavaScript Node runs. The VS Code guide says source maps are not always created automatically, so the transpiler has to be told to emit them; TypeScript does it with sourceMap in tsconfig.json.

Check
grep -n '"sourceMap"' tsconfig.json

Fix

Turn on sourceMap in tsconfig.json (the Firebase TypeScript template ships with it on) and rebuild so every .js gets a .js.map.

Fix
{
  "compilerOptions": {
    "outDir": "lib",
    "sourceMap": true
  }
}

Verify

After a rebuild, lib/index.js.map exists and the breakpoint turns solid red once the code loads.

Verify
npx tsc && ls lib/index.js.map

Confirmed by code.visualstudio.com

Did this fix it?

Cause 2 of 4

outFiles in launch.json does not cover the compiled folder

You seeMaps exist, but launch.json narrows outFiles to a folder like dist or out while the code really runs from lib (or the other way round)

Check

Only source maps inside outFiles are resolved by default, and the debugger finds the running .js for your .ts through those globs. The diagnose tool warns when outFiles has been narrowed, since the default already covers the whole workspace except node_modules.

Check
grep -n -A3 '"outFiles"' .vscode/launch.json

Fix

Point outFiles at the JavaScript files (not the .map files) in the folder the program runs from, or delete the entry and keep the default. For Firebase Functions attach to the emulator's inspector port.

Fix
{
  "name": "Attach to Functions emulator",
  "type": "node",
  "request": "attach",
  "port": 9229,
  "outFiles": ["${workspaceFolder}/functions/lib/**/*.js"]
}

Verify

Re-attach and trigger the function; execution pauses on the line in src/index.ts.

Verify
firebase emulators:start --only functions --inspect-functions

Confirmed by code.visualstudio.com

Did this fix it?

Cause 3 of 4

The running JavaScript is older than your TypeScript

You seeBreakpoints bind on some lines but not on code you just wrote, or the diagnose tool says your compiled code might be out of date with your sources

Check

The emulator and node run the files in lib, not src. If you edit the .ts without rebuilding, the map still describes the old file, and a breakpoint on a new line has nothing to bind to. The debugger also waits until a file is actually loaded before it binds breakpoints in it.

Check
ls -l src/index.ts lib/index.js

Fix

Rebuild before every debug run, or keep the compiler in watch mode in a second terminal while the emulator runs.

Fix
npx tsc --watch

Verify

lib/index.js has a newer time stamp than src/index.ts and the new line binds.

Verify
ls -lt src/index.ts lib/index.js

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 4 of 4

The source map points to paths that differ from your folder

You seeThe diagnose tool says it found other files with the same name, or the folder was opened with different letter case than on disk

Check

The debugger joins sourceRoot and sources from each map and looks for the exact path of your .ts. A bundler, a moved project or a different letter case in the opened folder breaks that match even though the map exists.

Check
node -e "const m=JSON.parse(require('fs').readFileSync('lib/index.js.map','utf8')); console.log(m.sourceRoot, m.sources)"

Fix

Fix sourceRoot in the build, or map the paths in launch.json with sourceMapPathOverrides (the left side matches the path written in the map, the right side is the file on disk). Reopen the folder using its real casing.

Fix
"sourceMapPathOverrides": {
  "webpack://@?:*/?:*/*": "${workspaceFolder}/*"
}

Verify

Debug: Diagnose Breakpoint Problems no longer lists the breakpoint, and it binds.

Verify
code .

Confirmed by code.visualstudio.com

Did this fix it?

How do I stop it coming back?

  • Keep sourceMap: true in the shared tsconfig.json and add a CI check that fails when the build output has no .js.map files.
  • Commit one attach configuration with an outFiles glob that matches your outDir, so each developer does not invent their own.
  • Run the compiler in watch mode alongside the emulator, so the code you debug is always the code you see.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Workforce, QistLock.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.