angular/angular-cli · error · CommandModuleError
Confguration file cannot be found.
Error message
Confguration file cannot be found.
What it means
After resolving the raw workspace config via getWorkspaceRaw (local angular.json or the global .angular-config), set() throws if either the config or its path is missing. This means no configuration file exists in which the requested JSON-path change can be written.
Source
Thrown at packages/angular/cli/src/commands/config/cli.ts:104
} else if (typeof value === 'string') {
logger.info(value);
} else {
logger.info(JSON.stringify(value, null, 2));
}
return 0;
}
private async set(options: Options<ConfigCommandArgs>): Promise<number | void> {
if (!options.jsonPath?.trim()) {
throw new CommandModuleError('Invalid Path.');
}
const [config, configPath] = await getWorkspaceRaw(options.global ? 'global' : 'local');
const { logger } = this.context;
if (!config || !configPath) {
throw new CommandModuleError('Confguration file cannot be found.');
}
const normalizeUUIDValue = (v: string | undefined) => (v === '' ? randomUUID() : `${v}`);
const value =
options.jsonPath === 'cli.analyticsSharing.uuid'
? normalizeUUIDValue(options.value)
: options.value;
const modified = config.modify(parseJsonPath(options.jsonPath), normalizeValue(value));
if (!modified) {
logger.error('Value cannot be found.');
return 1;
}
await validateWorkspace(parseJson(config.content), options.global ?? false);View on GitHub (pinned to bb72145f9a)
Solutions
- Run the command inside the Angular project directory containing angular.json
- If you intend the global config, verify it exists (~/.angular-config or the value of NG_CLI_ANALYTICS/global config location) before using --global
- Regenerate the workspace file (e.g. restore from VCS or `ng new`/`ng generate config` if applicable)
- Set the global configuration explicitly via NG_CONFIG or create the file with an empty {} JSON object before editing
Example fix
// before (outside project) ng config cli.defaultCollection my-lib // after cd my-angular-project && ng config cli.defaultCollection my-lib
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
const globalMode = options.global;
const configFile = globalMode ? (process.env.NG_CONFIG ?? `${homedir()}/.angular-config`) : 'angular.json';
if (!existsSync(configFile)) {
throw new Error(`Configuration file not found: ${configFile}. Run from an Angular project or create the global config.`);
} Type guard
function hasRawWorkspace(w: { config: unknown; path: string } | undefined | null)
: w is { config: unknown; path: string } {
return !!w && typeof w.path === 'string' && w.config != null;
} Try / catch
try {
await configCommand.run(options);
} catch (e) {
if (e instanceof CommandModuleError && e.message.includes('Confguration file cannot be found')) {
logger.error('No angular.json (or global config) found — run inside an Angular project.');
} else { throw e; }
} Prevention
- cd to the project root before running ng config
- Keep angular.json committed to VCS
- Only use --global when the global .angular-config file exists
- In CI, generate the workspace before attempting config edits
When it happens
Trigger: Running `ng config <path> <value>` in a directory with no angular.json (and --global not passed), or passing --global when no global .angular-config file exists / cannot be located.
Common situations: Executing the command outside an Angular project root; angular.json deleted or renamed; expecting `--global` to create a fresh global config file that isn't present; running in a CI workspace that never had angular.json generated.
Related errors
- Could not find ${level} workspace.
- Cannot retrieve cache configuration as workspace is not defi
- Workspace config file cannot be loaded: ${configPath}
- Invalid config found at ${workspace.filePath}. CLI should be
- Could not find a ${level} workspace. Are you in a project?
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/8bf76ce22361402c.
Report an issue: GitHub.