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 directoryCommon 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/]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.