{"record":{"id":"a12c81471a5f4733","repo":"angular/components","slug":"cannot-determine-project-target-configuration-for","errorCode":null,"errorMessage":"Cannot determine project target configuration for: ${buildTarget}.","messagePattern":"Cannot determine project target configuration for: (.+?)\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"src/cdk/schematics/utils/project-targets.ts","lineNumber":32,"sourceCode":"const PROJECT_BUILDERS = new Set([\n  '@angular-devkit/build-angular:browser-esbuild',\n  '@angular-devkit/build-angular:application',\n  '@angular-devkit/build-angular:browser',\n  '@angular/build:application',\n]);\n\n/** Possible name of CLI builders used to run tests in the project. */\nconst TEST_BUILDERS = new Set(['@angular-devkit/build-angular:karma', '@angular/build:karma']);\n\n/** Resolves the architect options for the build target of the given project. */\nexport function getProjectTargetOptions(\n  project: ProjectDefinition,\n  buildTarget: string,\n): Record<string, JsonValue | undefined> {\n  const options = project.targets?.get(buildTarget)?.options;\n\n  if (!options) {\n    throw new SchematicsException(\n      `Cannot determine project target configuration for: ${buildTarget}.`,\n    );\n  }\n\n  return options;\n}\n\n/** Gets all of the default CLI-provided build targets in a project. */\nexport function getProjectBuildTargets(project: ProjectDefinition): TargetDefinition[] {\n  return getTargetsByBuilderName(project, builder => !!builder && PROJECT_BUILDERS.has(builder));\n}\n\n/** Gets all of the default CLI-provided testing targets in a project. */\nexport function getProjectTestTargets(project: ProjectDefinition): TargetDefinition[] {\n  return getTargetsByBuilderName(project, builder => !!builder && TEST_BUILDERS.has(builder));\n}\n\n/** Gets all targets from the given project that pass a predicate check. */","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk/schematics/utils/project-targets.ts#L14-L50","documentation":"getProjectTargetOptions in src/cdk/schematics/utils/project-targets.ts fetches the options record of a named target (e.g. \"build\", \"test\", or \"serve\") from the project definition. If the target does not exist on the project or exists with no options, the schematic cannot read required configuration and throws this SchematicsException naming the missing buildTarget.","triggerScenarios":"Schematics that read target options — e.g. resolving styles (expectProjectStyleFile), buildOptions for the main file, or inline styles — when the requested target is absent: custom target names, renamed architect targets, library projects without a build target, or angular.json where the target defines only configurations and no base options.","commonSituations":"Nx or Bazel workspaces with non-standard target naming; users who deleted the \"test\" or \"build\" architect section; schematics run with a custom --configuration assumption; projects created outside Angular CLI.","solutions":["Ensure the project defines the expected target (usually \"build\") under projects.<name>.architect (or \"targets\") in angular.json.","Add an \"options\" object to that target — even minimal — so getProjectTargetOptions returns a record instead of undefined.","Run the schematic on an application project that has standard architect targets generated by the CLI.","If targets are defined only per-configuration, move the required keys (main, styles, index) into the base \"options\" block."],"exampleFix":"// before (angular.json)\n\"architect\": {}\n// after (angular.json)\n\"architect\": { \"build\": { \"builder\": \"@angular-devkit/build-angular:application\", \"options\": { \"main\": \"src/main.ts\" } } }","handlingStrategy":"validation","validationCode":"const p = JSON.parse(fs.readFileSync('angular.json', 'utf8')).projects[name];\nfor (const t of ['build', 'test']) {\n  if (!p?.architect?.[t]?.options) {\n    console.warn(`Project \"${name}\" is missing architect target \"${t}\" with base options; schematics may fail.`);\n  }\n}","typeGuard":"function hasTargetOptions(p: any, target: string): p is { architect: Record<string, { options: Record<string, unknown> }> } {\n  return !!p?.architect?.[target]?.options;\n}","tryCatchPattern":"try {\n  await runSchematic('styles', { project: name });\n} catch (e) {\n  if (String(e.message).includes('Cannot determine project target configuration')) {\n    console.error(`Target missing on \"${name}\"; add a build target with options in angular.json.`);\n  } else throw e;\n}","preventionTips":["Generate projects with Angular CLI so standard architect targets exist.","Never delete the base \"options\" block from build/test targets; use configurations for overrides.","In Nx workspaces, register conventional target names (build, serve, test) for Angular projects."],"tags":["angular","schematics","workspace-config","architect-targets"],"backgroundTag":"missing-build-option","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}