angular/angular-cli · error · Error
Webpack stats build result is required.
Error message
Webpack stats build result is required.
What it means
serveWebpackBrowser subscribes to the webpack build observable and each emitted build event must include webpackStats; stats drive public path resolution, address logging, and dev middleware behavior. A build event without stats indicates a malformed build result, so the server throws rather than serving without necessary metadata.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts:224
}
return {
browserOptions,
webpackConfig,
};
}
return from(setup()).pipe(
switchMap(({ browserOptions, webpackConfig }) => {
return runWebpackDevServer(webpackConfig, context, {
logging: transforms.logging || createWebpackLoggingCallback(browserOptions, logger),
webpackFactory: require('webpack') as typeof webpack,
webpackDevServerFactory: require('webpack-dev-server') as typeof webpackDevServer,
}).pipe(
concatMap(async (buildEvent, index) => {
const webpackRawStats = buildEvent.webpackStats;
if (!webpackRawStats) {
throw new Error('Webpack stats build result is required.');
}
// Resolve serve address.
const publicPath = webpackConfig.devServer?.devMiddleware?.publicPath;
const serverAddress = url.format({
protocol: options.ssl ? 'https' : 'http',
hostname: options.host === '0.0.0.0' ? 'localhost' : options.host,
port: buildEvent.port,
pathname: typeof publicPath === 'string' ? publicPath : undefined,
});
if (index === 0) {
logger.info(
'\n' +
tags.oneLine`
**
Angular Live Development Server is listening on ${options.host}:${buildEvent.port},View on GitHub (pinned to bb72145f9a)
Solutions
- Ensure the full build event (including webpackStats) is forwarded — remove map/reconstruct operations on the build observable.
- Align webpack/webpack-dev-server versions with those required by @angular-devkit/build-angular (clean reinstall).
- Remove or update custom transforms that touch webpackConfiguration and could suppress stats generation.
- Verify with a stock 'ng serve' on an unmodified project, then reintroduce customizations one at a time.
Example fix
// before
return build.pipe(map(ev => ({ ...ev, webpackStats: undefined })));
// after
return build; // keep webpackStats on every build event Defensive patterns
Strategy: type-guard
Validate before calling
import type { BuildEvent } from '@angular-devkit/build-angular';
function hasStats(ev: Partial<BuildEvent>): ev is BuildEvent & { webpackStats: NonNullable<BuildEvent['webpackStats']> } {
return !!ev.webpackStats;
} Type guard
const hasWebpackStats = (ev: { webpackStats?: unknown }): ev is { webpackStats: NonNullable<typeof ev.webpackStats> } =>
ev.webpackStats != null; Try / catch
try {
await startWebpackDevServer();
} catch (e) {
if (String(e.message).includes('Webpack stats build result is required')) {
// forward original build events; check webpack-dev-server version alignment
}
throw e;
} Prevention
- Forward webpack build events unmodified through wrappers
- Keep webpack and webpack-dev-server versions matched to build-angular
- Avoid replacing devMiddleware with custom implementations
- Test serve after every build-toolchain upgrade
When it happens
Trigger: A webpack build event reaches concatMap without webpackStats — caused by custom webpack configuration transforms stripping stats, incompatible/patched webpack or webpack-dev-server versions not attaching stats to dev middleware events, or wrapping/rebuilding the build observable and dropping fields.
Common situations: Custom dev-server wrappers or internal CLI tooling re-emitting build events; webpack-dev-server major version mismatch (v3/v4) after an incomplete upgrade; plugins that replace devMiddleware and omit stats output; running patched builds of @angular-devkit/build-angular.
Related errors
- Webpack stats build result is required.
- The "application" and "browser-esbuild" builders do not supp
- Only the "application" and "browser-esbuild" builders suppor
- Only the "application" and "browser-esbuild" builders suppor
- Webpack Dev Server configuration was not set.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/a25d7d43d5921a9f.
Report an issue: GitHub.