{"record":{"id":"da3f5587dde471dd","repo":"angular/angular-cli","slug":"option-project-is-required","errorCode":null,"errorMessage":"Option \"project\" is required.","messagePattern":"Option \"project\" is required\\.","errorType":"validation","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/angular/pwa/pwa/index.ts","lineNumber":74,"sourceCode":"      const chunks = [];\n      for await (const chunk of source) {\n        chunks.push(Buffer.from(chunk));\n      }\n      host.overwrite(path, Buffer.concat(chunks));\n    });\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 = [];","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/pwa/pwa/index.ts#L56-L92","documentation":"The @angular/pwa schematic requires an explicit target project when the workspace contains more than one project, or when the --project option is absent. The schematic throws SchematicsException to fail fast before reading workspace configuration further. It prevents silently adding PWA files to an unintended project.","triggerScenarios":"Running `ng add @angular/pwa` (or the pwa schematic) without --project in a multi-project workspace, or invoking the schematic programmatically with options.project undefined.","commonSituations":"Nx or ng multi-app workspaces, custom CI scripts calling the schematic without options, renamed projects so default project no longer matches.","solutions":["Re-run with an explicit project: ng add @angular/pwa --project my-app","Verify the project name in angular.json (projects key) matches the value passed to --project","Set 'defaultProject'/'cli.defaultProject' or pass the project interactively when prompted","If calling the schematic in code, pass { project: '<name>' } in options"],"exampleFix":"// before\nng generate @angular/pwa\n// after\nng generate @angular/pwa --project frontend-app","handlingStrategy":"validation","validationCode":"import { workspaces } from '@angular-devkit/core';\nconst ws = await workspaces.readWorkspace('angular.json');\nif (!options.project) throw new Error('Pass --project; available: ' + [...ws.projects.keys()].join(', '));","typeGuard":"function hasProject(o: { project?: string }): o is { project: string } {\n  return typeof o.project === 'string' && o.project.length > 0;\n}","tryCatchPattern":"try {\n  await schematicRunner.runSchematic('pwa', { project: 'my-app' });\n} catch (e) {\n  if (e instanceof SchematicsException && e.message.includes('Option \"project\"')) {\n    console.error('Supply --project with a name from angular.json');\n  }\n}","preventionTips":["Always pass --project explicitly in scripts/CI for multi-project workspaces","Validate the project name against angular.json before invoking schematics","Keep the default project set in angular.json for single-app workspaces"],"tags":["angular","schematics","cli","configuration"],"backgroundTag":"missing-required-option","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}