{"record":{"id":"0b40d607ac811f2d","repo":"angular/angular-cli","slug":"the-builder-requires-a-target-0b40d6","errorCode":null,"errorMessage":"The builder requires a target.","messagePattern":"The builder requires a target\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/builders/browser/index.ts","lineNumber":129,"sourceCode":"\n  return { config: transformedConfig || config, projectRoot, projectSourceRoot, i18n };\n}\n\n/**\n * @experimental Direct usage of this function is considered experimental.\n */\nexport function buildWebpackBrowser(\n  options: BrowserBuilderSchema,\n  context: BuilderContext,\n  transforms: {\n    webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;\n    logging?: WebpackLoggingCallback;\n    indexHtml?: IndexHtmlTransform;\n  } = {},\n): Observable<BrowserBuilderOutput> {\n  const projectName = context.target?.project;\n  if (!projectName) {\n    throw new Error('The builder requires a target.');\n  }\n\n  context.logger.warn(\n    'The \"@angular-devkit/build-angular:browser\" builder is deprecated as part of Angular\\'s Webpack support deprecation. ' +\n      'Use \"@angular/build:application\" instead. For more information, see https://angular.dev/tools/cli/build-system-migration.',\n  );\n\n  const baseOutputPath = path.resolve(context.workspaceRoot, options.outputPath);\n  let outputPaths: undefined | Map<string, string>;\n\n  // Check Angular version.\n  assertCompatibleAngularVersion(context.workspaceRoot);\n\n  return from(context.getProjectMetadata(projectName)).pipe(\n    switchMap(async (projectMetadata) => {\n      // Purge old build disk cache.\n      await purgeStaleBuildCache(context);\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/browser/index.ts#L111-L147","documentation":"buildWebpackBrowser requires an Architect target context (context.target.project) to resolve workspace configuration and options. Builders invoked outside a valid architect target context have no project, so the builder throws immediately before doing any work. It also warns that the browser builder is deprecated in favor of '@angular/build:application'.","triggerScenarios":"Calling the browser builder programmatically with a context lacking target info (e.g. context.target is undefined or target.project is empty), invoking the builder directly through the Architect API without scheduling it via a named target in angular.json, or using executeBuilder with a target that has no project set.","commonSituations":"Custom CLI scripts driving Architect directly; testing the builder with a mock context missing target; running a target definition whose 'project' key was typo'd or omitted; tooling that invokes builders without angular.json targets.","solutions":["Run the builder via a properly defined target in angular.json (ng build / ng run project:browser).","If invoking programmatically, ensure the ArchitectContext has target.project set (e.g. architect.scheduleTarget({ project, target, configuration })).","Migrate to the non-deprecated '@angular/build:application' builder, which also has clearer context requirements.","Check angular.json that the target belongs to an existing project and the project key is spelled correctly."],"exampleFix":"// before\narchitect.scheduleTarget({ target: 'build' }); // no project\n// after\narchitect.scheduleTarget({ project: 'my-app', target: 'build', configuration: 'production' });","handlingStrategy":"validation","validationCode":"import type { BuilderContext } from '@angular-devkit/architect';\nfunction assertTarget(context: BuilderContext): string {\n  const project = context.target?.project;\n  if (!project) throw new Error('Schedule this builder via a named target with a project.');\n  return project;\n}","typeGuard":"const hasTarget = (ctx: { target?: { project?: string } | null }): ctx is { target: { project: string } } =>\n  typeof ctx.target?.project === 'string' && ctx.target.project.length > 0;","tryCatchPattern":"try {\n  await scheduleBrowserBuild();\n} catch (e) {\n  if (String(e.message) === 'The builder requires a target.') {\n    // fix scheduling: use architect.scheduleTarget with project + target\n  }\n  throw e;\n}","preventionTips":["Always invoke builders through angular.json targets","Include project in scheduleTarget arguments","Avoid mock contexts without target in tests","Consider migrating to @angular/build:application"],"tags":["angular","builder","architect","configuration"],"backgroundTag":"builder-target-context-missing","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}