angular/angular-cli · error · SchematicsException
Project is not defined in this workspace.
Error message
Project is not defined in this workspace.
What it means
After the schematic validates that options.project is present, it looks the project up in the workspace (angular.json). If workspace.projects.get() returns undefined, the name does not correspond to any configured project and the schematic throws this SchematicsException.
Source
Thrown at packages/angular/pwa/pwa/index.ts:79
});
};
}
export default function (options: PwaOptions): Rule {
return async (host) => {
if (!options.title) {
options.title = options.project;
}
const workspace = await readWorkspace(host);
if (!options.project) {
throw new SchematicsException('Option "project" is required.');
}
const project = workspace.projects.get(options.project);
if (!project) {
throw new SchematicsException(`Project is not defined in this workspace.`);
}
if (project.extensions['projectType'] !== 'application') {
throw new SchematicsException(`PWA requires a project type of "application".`);
}
// Find all the relevant targets for the project
if (project.targets.size === 0) {
throw new SchematicsException(`Targets are not defined for this project.`);
}
const buildTargets = [];
const testTargets = [];
for (const target of project.targets.values()) {
if (
target.builder === '@angular-devkit/build-angular:browser' ||
target.builder === '@angular-devkit/build-angular:application' ||
target.builder === '@angular/build:application'View on GitHub (pinned to bb72145f9a)
Solutions
- Check angular.json 'projects' for exact available names and use one: ng add @angular/pwa --project <exact-name>
- Run `ng list` or read angular.json to confirm project names
- Navigate to the workspace root before running the command
- Re-add the missing project definition in angular.json if it was removed
Example fix
// before ng add @angular/pwa --project fronend // after ng add @angular/pwa --project frontend
Defensive patterns
Strategy: validation
Validate before calling
const angularJson = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const name = 'frontend';
if (!(name in angularJson.projects)) {
throw new Error(`Project "${name}" not found. Available: ${Object.keys(angularJson.projects).join(', ')}`);
} Type guard
function projectExists(ws: { projects: Map<string, unknown> }, name: string): boolean {
return ws.projects.has(name);
} Try / catch
try {
ngAdd('pwa', projectName);
} catch (e) {
if (String(e.message).includes('Project is not defined')) {
console.error(`Unknown project "${projectName}"; check angular.json projects key`);
}
} Prevention
- Copy project names exactly from angular.json (case-sensitive)
- Re-run schematics after renaming projects and update scripts
- Run from the workspace root so the correct angular.json is read
When it happens
Trigger: Passing a --project value that is not a key under 'projects' in angular.json, running in a directory whose workspace file does not define the named project, or typos/renamed projects.
Common situations: Typo in project name, project removed or renamed in angular.json, running ng add from the wrong directory, stale CI config referencing an old project name.
Related errors
- Option "project" is required.
- Targets are not defined for this project.
- Unknown package manager "${packageManagerName}".
- Package ${JSON.stringify(name)} was found but does not suppo
- Collection "${name}" does not have a schematics map.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/3be72f4df2ea3ca8.
Report an issue: GitHub.