angular/angular-cli · error · Error
Webpack Dev Server configuration was not set.
Error message
Webpack Dev Server configuration was not set.
What it means
After generating the webpack configuration via generateWebpackConfig (combining dev-server, common, and styles configs), setup() asserts that a devServer section exists. A missing devServer config means the generated config is structurally wrong (e.g. wrong mode/optimization resolution), so the server cannot be started and the builder throws.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts:131
logger.error(tags.stripIndents`
****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.
DON'T USE IT FOR PRODUCTION!
****************************************************************************************
`);
}
const { config, i18n } = await generateI18nBrowserWebpackConfigFromContext(
browserOptions,
context,
(wco) => [getDevServerConfig(wco), getCommonConfig(wco), getStylesConfig(wco)],
options,
);
if (!config.devServer) {
throw new Error('Webpack Dev Server configuration was not set.');
}
let locale: string | undefined;
if (i18n.shouldInline) {
// Dev-server only supports one locale
locale = [...i18n.inlineLocales][0];
} else if (i18n.hasDefinedSourceLocale) {
// use source locale if not localizing
locale = i18n.sourceLocale;
}
let webpackConfig = config;
// If a locale is defined, setup localization
if (locale) {
if (i18n.inlineLocales.size > 1) {
throw new Error(
'The development server only supports localizing a single locale per build.',View on GitHub (pinned to bb72145f9a)
Solutions
- Restore clean dev-server options in angular.json (regenerate the target or compare against a fresh project) and re-run.
- Reinstall/align @angular-devkit/build-angular and webpack-dev-server versions (delete node_modules and lockfile, reinstall).
- If custom code overrides config generation, ensure it spreads/keeps config.devServer instead of replacing the config.
- Run the stock 'ng serve' without custom builders/patches to isolate the source.
Example fix
// before (custom override)
webpackConfig = { ...webpackConfig, devServer: undefined };
// after
webpackConfig = { ...webpackConfig, devServer: { ...webpackConfig.devServer, port } }; Defensive patterns
Strategy: validation
Validate before calling
function assertDevServerConfig(config: { devServer?: unknown }): asserts config is { devServer: object } {
if (!config.devServer) {
throw new Error('Generated webpack config has no devServer section; check angular.json dev-server options and versions.');
}
} Type guard
const hasDevServer = (config: { devServer?: unknown }): config is { devServer: NonNullable<typeof config.devServer> } =>
config.devServer != null; Try / catch
try {
await ngServe();
} catch (e) {
if (String(e.message).includes('Webpack Dev Server configuration was not set')) {
// reset angular.json dev-server target options / reinstall aligned versions
}
throw e;
} Prevention
- Keep dev-server target options in angular.json valid and minimal
- Reinstall node_modules with a consistent lockfile after upgrades
- Avoid patching generateWebpackConfig or internal builder modules
- Verify 'ng serve' works on a fresh project before layering customizations
When it happens
Trigger: generateWebpackConfig returns a config without a devServer property — typically due to corrupted or unsupported angular.json dev-server options (e.g. malformed 'buildTarget'/'browserTarget', invalid options merged through), a customization/patch of the dev-server config generation, or an incompatible @angular-devkit/build-angular / webpack-dev-server version combination.
Common situations: Hand-edited angular.json with invalid dev-server option types; monkey-patched generateWebpackConfig or custom builder extensions that drop devServer; version mismatch after upgrading webpack-dev-server (v3 vs v4 API changes) breaking config generation; calling setup() directly in custom builders with a mis-built config.
Related errors
- 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 stats build result is required.
- Proxy configuration file ${proxyPath} does not exist.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/528c3b9c96e89ead.
Report an issue: GitHub.