angular/angular-cli · error · SchematicsException
Project target "build" not found.
Error message
Project target "build" not found.
What it means
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.`
Source
Thrown at packages/schematics/angular/server/index.ts:175
install,
}),
addDependency('@types/node', latestVersions['@types/node'], {
type: DependencyType.Dev,
install,
}),
]);
};
}
const serverSchematic: RuleFactory<ServerOptions> = createProjectSchematic(
async (options, { project, tree }) => {
if (project?.extensions.projectType !== 'application') {
throw new SchematicsException(`Server schematic requires a project type of "application".`);
}
const clientBuildTarget = project.targets.get('build');
if (!clientBuildTarget) {
throw targetBuildNotFoundError();
}
const usingApplicationBuilder = isUsingApplicationBuilder(project);
if (
project.targets.has('server') ||
(usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)
) {
// Server has already been added.
return noop();
}
const clientBuildOptions = clientBuildTarget.options as Record<string, string>;
const browserEntryPoint = await getMainFilePath(tree, options.project);
const isStandalone = isStandaloneApp(tree, browserEntryPoint);
const sourceRoot = project.sourceRoot ?? join(normalize(project.root), 'src');
let filesUrl = `./files/${View on GitHub (pinned to bb72145f9a)
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.
Example fix
// angular.json before
"my-lib": { "architect": { "test": { ... } } }
// after (run schematic against an app with a build target)
"ng add @angular/ssr --project my-app" // my-app has "architect": { "build": { ... } } Defensive patterns
Strategy: validation
Validate before calling
const project = workspace.projects.get(projectName);
if (project?.extensions.projectType !== 'application') throw new Error('Server schematic requires an application project');
if (!project.targets.get('build')) throw new Error('Add a build target in angular.json first'); Type guard
function hasBuildTarget(p?: { targets: { get(name: string): unknown } | null }): boolean {
return !!p?.targets.get('build');
} Try / catch
try {
await runSchematic('server', options);
} catch (err) {
if (!(err instanceof SchematicsException && err.message.includes('Project target "build" not found'))) throw err;
// add a build target or pick an application project
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot find 'options' for ${projectName} ${target} target.
- outputPath for ${projectName} ${target} target is not a stri
- Invalid project name (${projectName})
- Project target "build" not found.
- Project target "build" not found.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/47d19b7ac71a537b.
Report an issue: GitHub.