angular/angular-cli · error · Error
Invalid Webpack stats configuration.
Error message
Invalid Webpack stats configuration.
What it means
webpackStatsLogger prints formatted build stats. It requires config.stats to be an options object so it can compute which fields to print. If stats is a string preset (like 'minimal' or 'errors-only') or otherwise not an object, the formatter can't proceed and throws.
Source
Thrown at packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts:357
initialChunksCount,
changedChunksCount,
durationInMs: getBuildDuration(webpackStats),
cssSizeInBytes,
jsSizeInBytes,
ngComponentCount,
};
}
export function webpackStatsLogger(
logger: logging.LoggerApi,
json: StatsCompilation,
config: Configuration,
budgetFailures?: BudgetCalculatorResult[],
): void {
logger.info(statsToString(json, config.stats, budgetFailures));
if (typeof config.stats !== 'object') {
throw new Error('Invalid Webpack stats configuration.');
}
if (statsHasWarnings(json)) {
logger.warn(statsWarningsToString(json, config.stats));
}
if (statsHasErrors(json)) {
logger.error(statsErrorsToString(json, config.stats));
}
}
View on GitHub (pinned to bb72145f9a)
Solutions
- Set `stats` in your webpack config to an object (e.g. { all: false, errors: true, warnings: true }).
- Remove custom `stats` overrides so the CLI's default stats object is used.
- If using a custom builder, pass a resolved stats object into webpackStatsLogger instead of a string.
- Check for plugins that rewrite config.stats to a string preset and disable them.
Example fix
// before
module.exports = { stats: 'minimal' };
// after
module.exports = { stats: { all: false, errors: true, warnings: true, assets: true } }; Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof config.stats !== 'object' || config.stats === null) {
throw new TypeError('webpack config.stats must be an options object for webpackStatsLogger');
} Type guard
function isStatsObject(stats: Configuration['stats']): stats is StatsOptions {
return typeof stats === 'object' && stats !== null && !Array.isArray(stats);
} Try / catch
try {
webpackStatsLogger(logger, stats, config);
} catch (err) {
if (err.message === 'Invalid Webpack stats configuration.') {
logger.warn('stats was not an object; defaulting to verbose stats');
} else throw err;
} Prevention
- Never use string stats presets ('minimal','errors-only') with angular builders.
- Let the CLI set its own stats config unless you know the expected object shape.
- Watch for plugins that overwrite config.stats.
- Coerce preset strings to objects before passing Configuration to builders.
When it happens
Trigger: Calling webpackStatsLogger with a webpack Configuration whose `stats` field is a string preset or undefined/non-object — typically from custom webpack builder configs passing `stats: 'minimal'` or similar.
Common situations: Custom webpack configs copied from generic webpack examples where string stats presets are common; programmatic use of the browser/webpack builder with hand-built Configuration objects.
Related errors
- Webpack stats build result is required.
- Webpack Dev Server configuration was not set.
- Webpack stats build result is required.
- No options were specified to "postcss-cli-resources".
- Compilation output path cannot be empty.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/90379f27ae974df3.
Report an issue: GitHub.