angular/angular-cli · error · CommandModuleError
Invalid Path.
Error message
Invalid Path.
What it means
The `ng config` command's set() method writes a value into angular.json (or the global .angular-config) at a JSON path supplied via --json-path. If the path option is missing or only whitespace, it throws CommandModuleError('Invalid Path.') because there is nothing to target.
Source
Thrown at packages/angular/cli/src/commands/config/cli.ts:97
? jsonFile.get(parseJsonPath(options.jsonPath))
: jsonFile.content;
if (value === undefined) {
logger.error('Value cannot be found.');
return 1;
} 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));
View on GitHub (pinned to bb72145f9a)
Solutions
- Pass a full JSON path, e.g. `ng config cli.defaultCollection "@angular/scss"` or `ng config schematics.@schematics/angular.component.style scss`
- If using a shell variable, verify it is non-empty before invoking: echo "$PATH_VAR"
- Check quoting so the path isn't consumed by the shell
- Use `ng config --help` to confirm the expected argument order
Example fix
// before ng config "" newvalue // after ng config cli.defaultCollection newvalue
Defensive patterns
Strategy: validation
Validate before calling
if (!jsonPath || !jsonPath.trim()) {
throw new CommandModuleError('Invalid Path.');
}
await ngConfigSet(jsonPath, value); Type guard
function isValidJsonPathInput(p: string | undefined | null): p is string {
return typeof p === 'string' && p.trim().length > 0;
} Try / catch
try {
await configCommand.run({ jsonPath: myPath, value } as any);
} catch (e) {
if (e instanceof CommandModuleError && e.message === 'Invalid Path.') {
logger.error('Usage: ng config <json-path> <value>');
} else { throw e; }
} Prevention
- Quote JSON paths in the shell to prevent argument dropping
- Validate script variables are non-empty before invoking ng config
- Always pass path before value in argument order
- Sanitize user-supplied config paths with trim() before use
When it happens
Trigger: Running `ng config` set without the jsonPath argument (`ng config cli.defaultCollection` with no path), or passing an empty/whitespace-only path (`ng config " " value`).
Common situations: Shell quoting errors that drop the argument; scripting the command with a variable that resolves to empty string; typos like forgetting the key entirely while only passing a value.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Could not find ${level} workspace.
- Invalid config found at ${workspace.filePath}. CLI should be
- Cannot retrieve cache configuration as workspace is not defi
- Confguration file cannot be found.
- Invalid JSON path.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/ed07d393cf773e5e.
Report an issue: GitHub.