{"record":{"id":"363b69a0be61dd46","repo":"angular/angular-cli","slug":"the-builder-requires-a-target-363b69","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/prerender/index.ts","lineNumber":161,"sourceCode":"  } finally {\n    await Promise.all([browserTargetRun.stop(), serverTargetRun.stop()]);\n  }\n}\n\n/**\n * Renders each route and writes them to\n * <route>/index.html for each output path in the browser result.\n */\nasync function _renderUniversal(\n  options: PrerenderBuilderOptions,\n  context: BuilderContext,\n  browserResult: BrowserBuilderOutput,\n  serverResult: ServerBuilderOutput,\n  browserOptions: BrowserBuilderOptions,\n): Promise<PrerenderBuilderOutput> {\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(\n    context.workspaceRoot,\n    (projectMetadata.root as string | undefined) ?? '',\n  );\n\n  // Users can specify a different base html file e.g. \"src/home.html\"\n  const indexFile = getIndexOutputFile(browserOptions.index);\n  const { styles: normalizedStylesOptimization } = normalizeOptimization(\n    browserOptions.optimization,\n  );\n\n  let zonePackage: string | undefined;\n  try {\n    zonePackage = require.resolve('zone.js/node', { paths: [context.workspaceRoot] });\n  } catch {}","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/prerender/index.ts#L143-L179","documentation":"_renderUniversal combines browser and server build results to prerender pages and needs the project name from context.target to resolve project metadata (root, sourceRoot) for file operations. If context.target is missing or lacks a project, it throws 'The builder requires a target.' Same family as errors 153/155/157: programmatic invocation without an architect target.","triggerScenarios":"Executing the prerender builder through a custom Architect context without target.project; scheduling via scheduleBuilder instead of scheduleTarget; tooling that calls _renderUniversal/execute directly.","commonSituations":"Custom prerender scripts; test harnesses invoking the builder directly; workspaces where the builder is driven by external runners that omit target binding.","solutions":["Run prerender via `ng run <project>:prerender` so a target is bound.","Use scheduleTarget({ project, target: 'prerender' }) in programmatic usage.","If constructing contexts manually, ensure target: { project: '<name>' } is set.","Define the prerender target in angular.json for the project."],"exampleFix":"// before\nawait context.scheduleBuilder('@angular-devkit/build-angular:prerender', options);\n// after\nawait context.scheduleTarget({ target: 'prerender', project: 'my-app' }, options);","handlingStrategy":"validation","validationCode":"if (!context.target?.project) {\n  throw new Error('prerender requires a target: use ng run <project>:prerender.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await prerender(context, options);\n} catch (e) {\n  if (e.message === 'The builder requires a target.') {\n    console.error('Invoke prerender via ng run with a project target.');\n  } else throw e;\n}","preventionTips":["Schedule prerender with scheduleTarget, not scheduleBuilder.","Assert context.target.project before calling prerender internals.","Keep the prerender target defined in angular.json.","Centralize builder invocation in a helper that enforces target binding."],"tags":["prerender","angular","missing-target","ssr"],"backgroundTag":"missing-builder-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}