{"record":{"id":"47d19b7ac71a537b","repo":"angular/angular-cli","slug":"project-target-build-not-found","errorCode":null,"errorMessage":"Project target \"build\" not found.","messagePattern":"Project target \"build\" not found\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/server/index.ts","lineNumber":175,"sourceCode":"        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>;\n    const browserEntryPoint = await getMainFilePath(tree, options.project);\n    const isStandalone = isStandaloneApp(tree, browserEntryPoint);\n    const sourceRoot = project.sourceRoot ?? join(normalize(project.root), 'src');\n\n    let filesUrl = `./files/${","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/server/index.ts#L157-L193","documentation":"The `ng add @angular/ssr` / server schematic (packages/schematics/angular/server) requires the target Angular project to define a 'build' target, since it configures SSR around the client build. If project.targets.get('build') is undefined it throws targetBuildNotFoundError(), whose message is `Project target \"build\" not found.`","triggerScenarios":"Running the server schematic (ng add @angular/ssr, ng generate @schematics/angular:server, or ssr migration) against a project whose angular.json/architect definition has no 'build' target — typically a libs-only or custom-pipeline project.","commonSituations":"Adding SSR to a library project instead of an application; projects whose build is driven by a custom builder or external tool without an architect 'build' target; renamed or removed build target; malformed angular.json.","solutions":["Run the schematic on an application project (projectType: \"application\") that has a 'build' target.","Add or restore a 'build' target in the project's angular.json/architect section before generating SSR.","Specify a different existing project with `--project <name>` if the default project is a library.","Check angular.json for typos in the target name or a misplaced project definition."],"exampleFix":"// angular.json before\n\"my-lib\": { \"architect\": { \"test\": { ... } } }\n// after (run schematic against an app with a build target)\n\"ng add @angular/ssr --project my-app\" // my-app has \"architect\": { \"build\": { ... } }","handlingStrategy":"validation","validationCode":"const project = workspace.projects.get(projectName);\nif (project?.extensions.projectType !== 'application') throw new Error('Server schematic requires an application project');\nif (!project.targets.get('build')) throw new Error('Add a build target in angular.json first');","typeGuard":"function hasBuildTarget(p?: { targets: { get(name: string): unknown } | null }): boolean {\n  return !!p?.targets.get('build');\n}","tryCatchPattern":"try {\n  await runSchematic('server', options);\n} catch (err) {\n  if (!(err instanceof SchematicsException && err.message.includes('Project target \"build\" not found'))) throw err;\n  // add a build target or pick an application project\n}","preventionTips":["Only run the server/SSR schematic on application projects.","Verify a 'build' target exists in angular.json before running schematics.","Pass --project explicitly when the default project is a library.","Keep target names standard ('build') when customizing builds."],"tags":["schematics","ssr","angular-json","configuration"],"backgroundTag":"missing-build-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}