{"record":{"id":"d12ec2e8a8b316d9","repo":"angular/angular-cli","slug":"server-schematic-requires-a-project-type-of-appli","errorCode":null,"errorMessage":"Server schematic requires a project type of \"application\".","messagePattern":"Server schematic requires a project type of \"application\"\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/server/index.ts","lineNumber":170,"sourceCode":"        type: DependencyType.Default,\n        install,\n      }),\n      addDependency('@angular/platform-server', coreDep.version, {\n        type: DependencyType.Default,\n        install,\n      }),\n      addDependency('@types/node', latestVersions['@types/node'], {\n        type: DependencyType.Dev,\n        install,\n      }),\n    ]);\n  };\n}\n\nconst serverSchematic: RuleFactory<ServerOptions> = createProjectSchematic(\n  async (options, { project, tree }) => {\n    if (project?.extensions.projectType !== 'application') {\n      throw new SchematicsException(`Server schematic requires a project type of \"application\".`);\n    }\n\n    const clientBuildTarget = project.targets.get('build');\n    if (!clientBuildTarget) {\n      throw targetBuildNotFoundError();\n    }\n\n    const usingApplicationBuilder = isUsingApplicationBuilder(project);\n\n    if (\n      project.targets.has('server') ||\n      (usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)\n    ) {\n      // Server has already been added.\n      return noop();\n    }\n\n    const clientBuildOptions = clientBuildTarget.options as Record<string, string>;","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/server/index.ts#L152-L188","documentation":"Thrown by the server schematic when the resolved project's projectType extension is not \"application\" (e.g. it is a \"library\"). SSR server builds only make sense for applications, so the schematic refuses to proceed.","triggerScenarios":"Running `ng generate @angular/ssr:server --project <lib>` against a library project (project.extensions.projectType === 'library'), or a project whose angular.json entry lacks projectType: application.","commonSituations":"Trying to add SSR to an Angular library; projects hand-created in angular.json without the projectType extension; running the schematic with the wrong --project name pointing at a library in a monorepo.","solutions":["Re-run the schematic targeting an application: `ng g @angular/ssr:server --project <app-name>`.","If the target should be an app, fix projectType to \"application\" in angular.json (and provide build/target config).","Add SSR only to application projects; libraries cannot host an SSR server build.","Check `ng list` to confirm which workspace entries are applications."],"exampleFix":"// before (angular.json)\n\"my-lib\": { \"projectType\": \"library\", ... }\n// after — run against the app instead\n\"my-app\": { \"projectType\": \"application\", ... }","handlingStrategy":"validation","validationCode":"const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst p = ws.projects?.[projectName];\nif (p?.projectType !== 'application') {\n  throw new Error(`Project '${projectName}' is not an application; SSR schematic will fail.`);\n}","typeGuard":"function isApplication(p: { projectType?: string } | undefined): p is { projectType: 'application' } {\n  return p?.projectType === 'application';\n}","tryCatchPattern":"try {\n  await generateServerSchematic({ project: projectName });\n} catch (e) {\n  if (String(e.message).includes('project type of \"application\"')) {\n    console.error(`'${projectName}' is not an application. Target an app project.`);\n  } else throw e;\n}","preventionTips":["Only run server/SSR schematics on application projects","Verify projectType in angular.json for hand-created projects","Double-check --project names in monorepos","Use `ng list` to distinguish apps from libraries"],"tags":["angular","schematics","project-type","ssr"],"backgroundTag":"wrong-project-type","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}