angular/angular-cli · error · CommandModuleError
Cannot determine project or target.
Error message
Cannot determine project or target.
What it means
The run command's run() method throws this when makeTargetSpecifier returns undefined, meaning the provided options could not be resolved into a project:target target specifier. Neither a direct --target/--project combination nor positional args produced a runnable target.
Source
Thrown at packages/angular/cli/src/commands/run/cli.ts:81
}, true)
.strict();
const target = this.makeTargetSpecifier();
if (!target) {
return localYargs;
}
const schemaOptions = await this.getArchitectTargetOptions(target);
return this.addSchemaOptionsToCommand(localYargs, schemaOptions);
}
async run(options: Options<RunCommandArgs> & OtherOptions): Promise<number> {
const target = this.makeTargetSpecifier(options);
const { target: _target, ...extraOptions } = options;
if (!target) {
throw new CommandModuleError('Cannot determine project or target.');
}
return this.runSingleTarget(target, extraOptions);
}
protected makeTargetSpecifier(options?: Options<RunCommandArgs>): Target | undefined {
const architectTarget = options?.target ?? this.context.args.positional[1];
if (!architectTarget) {
return undefined;
}
const [project = '', target = '', configuration] = architectTarget.split(':');
return {
project,
target,
configuration,
};View on GitHub (pinned to bb72145f9a)
Solutions
- Provide an explicit target: `ng run my-project:build` or `ng build my-project`.
- Check angular.json contains the referenced project/target.
- Set "defaultProject" in angular.json or run from inside a project directory.
Example fix
// before ng run // after ng run my-app:serve:development
Defensive patterns
Strategy: validation
Validate before calling
const ng = require('./angular.json');
const hasTarget = options.target || (options.project && ng.projects[options.project]);
if (!hasTarget) {
throw new Error('Provide an explicit project:target, e.g. ng run my-app:build');
} Type guard
function canResolveTarget(o: { target?: string; project?: string }): boolean {
return typeof o.target === 'string' || typeof o.project === 'string';
} Prevention
- Always pass explicit project:target to `ng run`.
- Run architect commands from a directory inside a project.
- Set defaultProject in angular.json for single-project workspaces.
When it happens
Trigger: Running `ng run` (or `ng <builder>`) with no positional 'project:target' argument and no project/target options; running `ng <architect command>` in a context where no project and no default target can be resolved.
Common situations: `ng run` with no arguments; running an architect command outside a project directory in a multi-project repo; missing defaultProject in angular.json; typo making the positional arg unparseable.
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
- Project '${projectName}' not found in workspace path ${works
- Unknown argument: configuration. Provide the configuration a
- A single package must be specified when using the 'migrate-o
- No project name provided and no default project found in wor
- Repository is not clean. Please commit or stash any changes
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/3fd09a266653feda.
Report an issue: GitHub.