{"record":{"id":"3be72f4df2ea3ca8","repo":"angular/angular-cli","slug":"project-is-not-defined-in-this-workspace","errorCode":null,"errorMessage":"Project is not defined in this workspace.","messagePattern":"Project is not defined in this workspace\\.","errorType":"validation","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/angular/pwa/pwa/index.ts","lineNumber":79,"sourceCode":"    });\n  };\n}\n\nexport default function (options: PwaOptions): Rule {\n  return async (host) => {\n    if (!options.title) {\n      options.title = options.project;\n    }\n\n    const workspace = await readWorkspace(host);\n\n    if (!options.project) {\n      throw new SchematicsException('Option \"project\" is required.');\n    }\n\n    const project = workspace.projects.get(options.project);\n    if (!project) {\n      throw new SchematicsException(`Project is not defined in this workspace.`);\n    }\n\n    if (project.extensions['projectType'] !== 'application') {\n      throw new SchematicsException(`PWA requires a project type of \"application\".`);\n    }\n\n    // Find all the relevant targets for the project\n    if (project.targets.size === 0) {\n      throw new SchematicsException(`Targets are not defined for this project.`);\n    }\n\n    const buildTargets = [];\n    const testTargets = [];\n    for (const target of project.targets.values()) {\n      if (\n        target.builder === '@angular-devkit/build-angular:browser' ||\n        target.builder === '@angular-devkit/build-angular:application' ||\n        target.builder === '@angular/build:application'","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/pwa/pwa/index.ts#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nng add @angular/pwa --project fronend\n// after\nng add @angular/pwa --project frontend","handlingStrategy":"validation","validationCode":"const angularJson = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst name = 'frontend';\nif (!(name in angularJson.projects)) {\n  throw new Error(`Project \"${name}\" not found. Available: ${Object.keys(angularJson.projects).join(', ')}`);\n}","typeGuard":"function projectExists(ws: { projects: Map<string, unknown> }, name: string): boolean {\n  return ws.projects.has(name);\n}","tryCatchPattern":"try {\n  ngAdd('pwa', projectName);\n} catch (e) {\n  if (String(e.message).includes('Project is not defined')) {\n    console.error(`Unknown project \"${projectName}\"; check angular.json projects key`);\n  }\n}","preventionTips":["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"],"tags":["angular","schematics","configuration"],"backgroundTag":"project-not-found-in-workspace","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}