{"record":{"id":"7ece1b816cd2f0d5","repo":"angular/angular-cli","slug":"pwa-requires-a-project-type-of-application","errorCode":null,"errorMessage":"PWA requires a project type of \"application\".","messagePattern":"PWA requires a project type of \"application\"\\.","errorType":"validation","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/angular/pwa/pwa/index.ts","lineNumber":83,"sourceCode":"export 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'\n      ) {\n        buildTargets.push(target);\n      } else if (\n        target.builder === '@angular-devkit/build-angular:karma' ||","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/pwa/pwa/index.ts#L65-L101","documentation":"The PWA schematic only supports application-type projects. After locating the project, it checks project.extensions['projectType'] and throws if it is not 'application' (e.g. a library project).","triggerScenarios":"Running ng add @angular/pwa --project <name> where <name> is a library (projectType: 'library') in angular.json.","commonSituations":"Targeting an ng generate library project, monorepo setups where the chosen project is a shared lib instead of the app.","solutions":["Target the application project instead: ng add @angular/pwa --project my-app","If the wrong projectType was set, fix angular.json: set extensions.projectType to 'application' for that project","Create a new application project and apply PWA to it rather than the library"],"exampleFix":"// before (angular.json)\n\"my-lib\": { \"projectType\": \"library\", ... }\n// after (use the app project instead)\nng add @angular/pwa --project my-app","handlingStrategy":"validation","validationCode":"const p = angularJson.projects[name];\nif (p?.extensions?.projectType !== 'application') {\n  throw new Error(`${name} is not an application project`);\n}","typeGuard":"function isApplicationProject(p: { extensions?: { projectType?: string } } | undefined): boolean {\n  return p?.extensions?.projectType === 'application';\n}","tryCatchPattern":"try {\n  await runPwaSchematic(projectName);\n} catch (e) {\n  if (String(e.message).includes('project type of \"application\"')) {\n    console.error(`${projectName} is a library; target the application project instead`);\n  }\n}","preventionTips":["Only apply the PWA schematic to projects with projectType 'application'","In monorepos, keep a mapping of app vs lib projects in your scripts","Check angular.json extensions before targeting a project programmatically"],"tags":["angular","pwa","configuration"],"backgroundTag":"unsupported-project-type","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}