{"record":{"id":"c3c3a6e6f8b5d4d0","repo":"angular/angular-cli","slug":"the-builder-requires-a-target","errorCode":null,"errorMessage":"The builder requires a target.","messagePattern":"The builder requires a target\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/builders/app-shell/index.ts","lineNumber":54,"sourceCode":"  const browserTarget = targetFromTargetString(options.browserTarget);\n  const rawBrowserOptions = await context.getTargetOptions(browserTarget);\n  const browserBuilderName = await context.getBuilderNameForTarget(browserTarget);\n  const browserOptions = await context.validateOptions<JsonObject & BrowserBuilderSchema>(\n    rawBrowserOptions,\n    browserBuilderName,\n  );\n\n  // Locate zone.js to load in the render worker\n  const root = context.workspaceRoot;\n  let zonePackage: string | undefined;\n\n  try {\n    zonePackage = require.resolve('zone.js', { paths: [root] });\n  } catch {}\n\n  const projectName = context.target && context.target.project;\n  if (!projectName) {\n    throw new Error('The builder requires a target.');\n  }\n\n  const projectMetadata = await context.getProjectMetadata(projectName);\n  const projectRoot = path.join(root, (projectMetadata.root as string | undefined) ?? '');\n\n  const { styles } = normalizeOptimization(browserOptions.optimization);\n  let inlineCriticalCssProcessor;\n  if (styles.inlineCritical) {\n    const { InlineCriticalCssProcessor } = await import('@angular/build/private');\n    inlineCriticalCssProcessor = new InlineCriticalCssProcessor({\n      minify: styles.minify,\n      deployUrl: browserOptions.deployUrl,\n    });\n  }\n\n  const renderWorker = new Piscina({\n    filename: require.resolve('./render-worker'),\n    maxThreads: 1,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts#L36-L72","documentation":"The app-shell builder's _renderUniversal needs context.target.project to know which Angular project to render and to look up project metadata. Architect contexts normally carry a target; this error means the builder was invoked without one, so the target project cannot be resolved.","triggerScenarios":"Executing the app-shell builder through an API path that passes no target (e.g. calling the builder function directly with a hand-built context lacking target), or scheduling it without a target specification.","commonSituations":"Custom tooling invoking builder functions programmatically with partially constructed ArchitectBuildContext; test harnesses that build contexts manually; integrations that call builders outside `ng run` / architect.scheduleTarget.","solutions":["Run the builder via ng run <project>:app-shell or architect.scheduleTarget() with a proper target spec.","If constructing a context manually, set context.target = { project: 'your-app', builder: '...', target: 'app-shell' }.","Ensure angular.json contains the project referenced by the target."],"exampleFix":"// before (manual context)\nawait appShellBuilder(options, { root, workspaceRoot, logger } as any);\n// after\nconst context = { root, workspaceRoot, logger, target: { project: 'my-app', target: 'app-shell', configuration: 'production' } } as any;\nawait appShellBuilder(options, context);\n// or preferably: architect.scheduleTarget({ project: 'my-app', target: 'app-shell' })","handlingStrategy":"validation","validationCode":"if (!context.target || !context.target.project) {\n  throw new Error('app-shell must be scheduled via a target, e.g. ng run my-app:app-shell');\n}","typeGuard":"function hasTargetProject(context: BuilderContext): context is BuilderContext & { target: { project: string } } {\n  return typeof context.target?.project === 'string';\n}","tryCatchPattern":"try {\n  await architect.scheduleTarget({ project: 'my-app', target: 'app-shell' });\n} catch (e) {\n  if (e.message.includes('The builder requires a target')) {\n    console.error('Invoke the builder with a valid target, not a bare function call');\n  } else { throw e; }\n}","preventionTips":["Always invoke builders through ng run or architect.scheduleTarget().","When building contexts for tests, populate target.project.","Ensure angular.json defines the project before running app-shell."],"tags":["angular-cli","app-shell","architect-builder","target"],"backgroundTag":"missing-build-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}