{"record":{"id":"7d5a19a468fd8cda","repo":"angular/angular-cli","slug":"project-target-build-not-found-7d5a19","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/utility/standalone/util.ts","lineNumber":28,"sourceCode":"import { join } from 'node:path/posix';\nimport ts from 'typescript';\nimport { Change, applyToUpdateRecorder } from '../change';\nimport { targetBuildNotFoundError } from '../project-targets';\nimport { getWorkspace } from '../workspace';\nimport { Builders } from '../workspace-models';\n\n/**\n * Finds the main file of a project.\n * @param tree File tree for the project.\n * @param projectName Name of the project in which to search.\n */\nexport async function getMainFilePath(tree: Tree, projectName: string): Promise<string> {\n  const workspace = await getWorkspace(tree);\n  const project = workspace.projects.get(projectName);\n  const buildTarget = project?.targets.get('build');\n\n  if (!project || !buildTarget) {\n    throw targetBuildNotFoundError();\n  }\n\n  const options = buildTarget.options as Record<string, string>;\n\n  if (\n    buildTarget.builder === Builders.Application ||\n    buildTarget.builder === Builders.BuildApplication\n  ) {\n    // These builders support a default of `<project_source_root>/main.ts`\n    const projectSourceRoot = project.sourceRoot ?? join(project.root, 'src');\n\n    return options.browser ?? join(projectSourceRoot, 'main.ts');\n  }\n\n  return options.main;\n}\n\n/**","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/utility/standalone/util.ts#L10-L46","documentation":"getMainFilePath in packages/schematics/angular/utility/standalone/util.ts resolves a project's main file via its 'build' target options. If the project or its 'build' target does not exist it throws targetBuildNotFoundError(), producing `Project target \"build\" not found.` It is shared by the browser-entry-point and main-file-path logic of several schematics.","triggerScenarios":"Any schematic that calls getMainFilePath (standalone migration, service-worker, app-shell, SSR flows) against a project lacking a 'build' target in angular.json, or with a project name that doesn't exist in the workspace.","commonSituations":"Custom build pipelines without an architect 'build' target; Bazel or Nrwl/Nx setups where targets live under different names; typo'd --project name; pre-v17 workspaces using 'browser' or 'deployment' targets only with the build target deleted.","solutions":["Ensure the project has a standard 'build' target (builder @angular-devkit/build-angular:browser or @angular/build:application) in angular.json.","Pass the correct application project name via --project.","If using a custom builder setup, add an alias 'build' target pointing at your build configuration.","Verify the project name exists with `ng config projects` / the projects section of angular.json."],"exampleFix":"// before\n\"architect\": { \"compile\": { \"builder\": \"@angular-devkit/build-angular:browser\", ... } }\n// after\n\"architect\": { \"build\": { \"builder\": \"@angular-devkit/build-angular:browser\", ... } }","handlingStrategy":"validation","validationCode":"const project = workspace.projects.get(projectName);\nif (!project?.targets.get('build')) {\n  throw new Error(`Project ${projectName} has no build target; getMainFilePath will fail`);\n}","typeGuard":"function canResolveMainFilePath(p?: { targets: { get(name: string): { builder: string } | null } | null }): boolean {\n  return !!p?.targets.get('build');\n}","tryCatchPattern":"try {\n  const main = await getMainFilePath(tree, projectName);\n} catch (err) {\n  if (!(err instanceof SchematicsException && err.message.includes('Project target \"build\" not found'))) throw err;\n  // fall back to manually configured main path or fix angular.json\n}","preventionTips":["Standardize on a 'build' target in every application's angular.json.","Pass exact project names to schematics.","For custom toolchains, add an alias 'build' architect target.","Validate workspace targets before running migration schematics."],"tags":["schematics","standalone","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"}