angular/angular-cli · error · Error
Webpack configuration file ${configPath} does not exist.
Error message
Webpack configuration file ${configPath} does not exist. What it means
getWebpackConfig loads a custom webpack configuration file given by path. If the file does not exist on disk (existsSync check fails), the build stops with this error instead of silently building with defaults. It guarantees an explicitly configured webpack config must actually be present and loadable.
Source
Thrown at packages/angular_devkit/build_webpack/src/utils.ts:60
}
}
// add all other files
for (const file of Object.keys(compilation.assets)) {
// Chunk files have already been added to the files list above
if (chunkFileNames.has(file)) {
continue;
}
files.push({ file, extension: path.extname(file), initial: false, asset: true });
}
return files;
}
export async function getWebpackConfig(configPath: string): Promise<Configuration> {
if (!existsSync(configPath)) {
throw new Error(`Webpack configuration file ${configPath} does not exist.`);
}
const config = await import(configPath);
return 'default' in config ? config.default : config;
}
View on GitHub (pinned to bb72145f9a)
Solutions
- Correct the path in your builder options so it points at the existing webpack config file
- Use an absolute path (path.resolve(__dirname, 'webpack.config.js')) or verify what directory the path is resolved from
- Create the missing webpack config file if it was never committed; ensure it isn't gitignored or excluded in CI
Example fix
// before
"customWebpackConfig": { "path": "webpack.config.js" } // file lives at apps/my-app/webpack.config.js
// after
"customWebpackConfig": { "path": "apps/my-app/webpack.config.js" } Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
import { resolve } from 'path';
const abs = resolve(workspaceRoot, configPath);
if (!existsSync(abs)) {
throw new Error(`Webpack configuration file ${abs} does not exist. Check customWebpackConfig.path relative to ${workspaceRoot}.`);
} Type guard
null
Try / catch
try {
const cfg = await getWebpackConfig(configPath);
} catch (e) {
if ((e as Error).message.includes('does not exist')) {
// log the resolved absolute path and the workspace root to debug path resolution
}
throw e;
} Prevention
- Store webpack config paths relative to the workspace root and document that convention
- Commit the webpack config; never list it in .gitignore
- Resolve to absolute paths in shared build scripts before passing options
- Smoke-test custom webpack config loading in CI before full builds
When it happens
Trigger: Passing a webpackConfigPath (customWebpackConfig.path in build_webpack usage) that doesn't exist: typoed filename, relative path not resolved from the expected working directory, or file deleted/renamed.
Common situations: angular.json or custom builder options referencing 'webpack.config.js' that lives in a different directory than assumed, monorepo setups where the config is per-package and the path is relative to workspace root not project root, CI checkouts excluding the config file (e.g. .gitignore or sparse checkout).
Related errors
- Webpack Dev Server configuration was not set.
- No options were specified to "postcss-cli-resources".
- Compilation output path cannot be empty.
- Invalid Webpack stats configuration.
- Multiple bundles have been named the same: '${duplicates.joi
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/3e20961f469595d9.
Report an issue: GitHub.