parcel-bundler/parcel · error · Error
Source map not found
Error message
Source map not found
What it means
Thrown by HMRServer.findSourceMap after every classification branch has been exhausted. The method maps an incoming path to one of three location types: 'bundle' if inside distDir, 'source' if inside projectRoot, otherwise it throws. So the file the client asked a source map for is neither in the build output nor inside the project tree.
Source
Thrown at packages/reporters/dev-server/src/HMRServer.js:619
if (filePath.startsWith('/') || path.isAbsolute(filePath)) {
filePath = path.normalize(filePath);
} else {
filePath = path.join(distDir, filePath);
}
// If the file is inside the distDir, it's a bundle path.
if (isDirectoryInside(filePath, distDir)) {
return {type: 'bundle', filePath: filePath};
}
// Otherwise, assume this refers to a source file.
// This can happen if the server uses --enable-source-maps,
// in which case Node will have already mapped the location.
if (isDirectoryInside(filePath, this.options.projectRoot)) {
return {type: 'source', filePath};
}
throw new Error('Source map not found');
}
}
function getSpecifier(dep: Dependency): string {
if (typeof dep.meta.placeholder === 'string') {
return dep.meta.placeholder;
}
return dep.specifier;
}
function getCodeFrame(
line: number,
column: number,
source: string,
contextLines: number,
language: string,
): string {View on GitHub (pinned to 59484858a1)
Solutions
- Compare the failing filePath against your projectRoot and distDir; if it legitimately belongs to the project, make sure it is under projectRoot (or extend projectRoot).
- Verify publicUrl is set correctly so prefix stripping does not corrupt the path.
- If the frame is from an external dependency, expect Parcel to decline — that is correct behavior; remap externally or ignore.
- For symlinked monorepo packages, ensure the real path resolves under projectRoot (configure packageManager/workspace roots).
Defensive patterns
Strategy: validation
Validate before calling
// Confirm a path lives in projectRoot or distDir before requesting its map
const path = require('path');
function isCovered(filePath, projectRoot, distDir) {
const rel = path.relative(projectRoot, filePath);
const inProject = rel && !rel.startsWith('..');
const inDist = !path.relative(distDir, filePath).startsWith('..');
return Boolean(inProject || inDist);
} Prevention
- Keep all source under projectRoot; avoid resolving sources into global node_modules.
- Set publicUrl consistently so HMRServer's prefix stripping yields a valid in-project path.
When it happens
Trigger: A source-map request whose filePath, after stripping publicUrl / file:// / rsc:// prefixes and normalizing, resolves to an absolute path outside both distDir and projectRoot. Commonly a stack frame from a dependency resolved outside the project (e.g. in a global node_modules) or a path that lost its leading slash through URL handling.
Common situations: Stack frames pointing into a globally-installed package or a pnpm virtual store outside projectRoot; symlinked source roots not under projectRoot; misconfigured publicUrl that leaves the path malformed; rsc:// URL parsing edge cases where the pathname slice yields a bogus path.
Related errors
- Asset does not have a source map
- More than one target is not supported in serve mode
- Could not get available port: ${err.message}
- Certificate and/or key not found
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/d8690932f7e44133.
Report an issue: GitHub.