Webpack source-map-loader "Failed to parse source map" - Fix in CI
source-map-loader tries to load each module's referenced source map. When a dependency points at a .map that is missing or malformed, the loader emits a warning per file. On CRA or CI=true builds that treat warnings as errors, those warnings fail the build.
What this error means
The build floods with Failed to parse source map from '<node_modules path>': Error: ENOENT warnings, and in CI (warnings-as-errors) the build then fails. The warnings point inside node_modules, not your code.
WARNING in ./node_modules/some-lib/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/app/node_modules/some-lib/src/index.ts'
file: Error: ENOENT: no such file or directoryDiagnose it: is it resolution, transform, or memory?
Bundler failures in CI fall into three families and the error text often points at the wrong one. A module that resolves on your machine and not on the runner is nearly always case sensitivity or a missing optional dependency; a transform error is a config or version mismatch; and an unexplained kill with no stack is the out-of-memory reaper, not a build error at all.
# 1. resolution: does the file exist with EXACTLY that case?
git ls-files | grep -i "the/imported/path"
# 2. transform: what versions is CI actually resolving?
npm ls webpack vite rollup esbuild typescript 2>/dev/null | head -20
# 3. memory: was it killed rather than failed?
# exit 137 = SIGKILL (OOM). Nothing in the bundler log will explain it.
node --max-old-space-size=4096 node_modules/.bin/vite buildCommon causes
A dependency ships a bad sourceMappingURL
The published package references a source map (//# sourceMappingURL=...) that was not included in the npm tarball, so source-map-loader cannot find it.
CI treats warnings as errors
Create React App and many pipelines set CI=true, which promotes warnings to errors - so otherwise-harmless source-map warnings fail the build.
How to fix it
Exclude node_modules from source-map-loader
Only process your own source for maps, so broken dependency maps are ignored.
// webpack.config.js
{
test: /\.[cm]?js$/,
enforce: 'pre',
use: ['source-map-loader'],
exclude: /node_modules/,
}Ignore the specific warning (CRA)
When you cannot edit the loader config, silence the known-harmless warning.
# .env (Create React App)
GENERATE_SOURCEMAP=false
# or filter the warning via ignoreWarnings in a custom config:
# ignoreWarnings: [/Failed to parse source map/]Make the build reproducible before you debug it
- Pin the Node major in
setup-nodeand inengines. A bundler that resolves native bindings will pick a different prebuilt binary across majors. - Delete
node_moduleslocally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state. - Set
CI=truelocally to reproduce. Several toolchains change behaviour under it, including treating warnings as errors. - Exit code 137 is an out-of-memory kill. Raise
--max-old-space-sizeor move to a larger runner rather than searching the bundler config.
How to prevent it
- Exclude
node_modulesfromsource-map-loader. - Use
ignoreWarningsto filter known third-party source-map noise. - Decide deliberately whether CI should treat warnings as errors.