facebook/react · error · Error
The source map has more mappings than there are lines.
Error message
The source map has more mappings than there are lines.
What it means
ReactFlightWebpackNodeLoader instruments 'use client'/'use server' modules and merges the file's existing source map with the mappings it inserts. As a consistency check it compares the number of mapped lines against program.loc.end.line of the actual source; if the source map claims mappings past the last line of the file, the map cannot belong to this source, so the loader refuses to continue.
Source
Thrown at packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js:364
exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;
exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;
exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;
}
}
for (
let lastIdx = mappings.length - 1;
lastIdx >= 0 && mappings[lastIdx] === ';';
lastIdx--
) {
// If the last mapped lines don't contain any segments, we don't get a callback from readMappings
// so we need to pad the number of mapped lines, with one for each empty line.
lastMappedLine++;
}
sourceLineCount = program.loc.end.line;
if (sourceLineCount < lastMappedLine) {
throw new Error(
'The source map has more mappings than there are lines.',
);
}
// If the original source string had more lines than there are mappings in the source map.
// Add some extra padding of unmapped lines so that any lines that we add line up.
for (
let extraLines = sourceLineCount - lastMappedLine;
extraLines > 0;
extraLines--
) {
mappings += ';';
}
} else {
// If a file doesn't have a source map then we generate a blank source map that just
// contains the original content and segments pointing to the original lines.
sourceLineCount = 1;
let idx = -1;
while ((idx = source.indexOf('\n', idx + 1)) !== -1) {View on GitHub (pinned to eafeac097b)
Solutions
- Regenerate source maps for the file so they match the current source exactly
- Reorder/repair the transform chain so each stage's map corresponds to its input (source-map chaining)
- If the map is expendable, remove the sourceMappingURL comment for that file so the loader skips merging
- Pin consistent tool versions across the chain so map semantics do not drift
Example fix
# before: stale map next to a regenerated source src/Component.js (edited, now 120 lines) src/Component.js.map (maps 130 lines) # after: rebuild maps in the same pass as sources npx babel src --out-dir lib --source-maps # or drop the stale map rm src/Component.js.map # loader then skips source-map merging
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate maps before the loader sees them
import fs from 'fs';
function mapIsValid(jsPath, mapPath) {
const map = JSON.parse(fs.readFileSync(mapPath, 'utf8'));
const mappedLines = map.mappings.split(';').length;
const srcLines = fs.readFileSync(jsPath, 'utf8').split('\n').length;
return mappedLines <= srcLines;
} Prevention
- Regenerate sources and maps in the same toolchain pass
- Chain source maps properly at every transform step
- Delete orphaned .map files when sources change
When it happens
Trigger: A processed file carries a sourceMappingURL whose map has more mapping lines than the file has lines — typically a map generated from a different (longer) version of the file, a misaligned transform step, or a truncated/malformed mappings field.
Common situations: Chained Babel/TS/SWC transforms where a later stage emits a map for the pre-transform source | Stale .map files next to regenerated sources | Tools that append or strip lines (shebang removal, banner plugins) without updating the map
Related errors
- The source map has more mappings than there are lines.
- The source map has more mappings than there are lines.
- Could not find the module "${modulePath}" in the React Clien
- The module "${modulePath}" is marked as an async ESM module
- Use react-server-dom-webpack/client instead.
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/38ff5d29b5c3cc51.
Report an issue: GitHub.