{"record":{"id":"76278ffb599fe175","repo":"angular/angular-cli","slug":"build-target-is-not-defined-for-this-project","errorCode":null,"errorMessage":"Build target is not defined for this project.","messagePattern":"Build target is not defined for this project\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/web-worker/index.ts","lineNumber":113,"sourceCode":"\n    const root = project.root || '';\n    const templateSourceWorkerConfig = apply(url('./files/worker-tsconfig'), [\n      applyTemplates({\n        ...options,\n        relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(root),\n      }),\n      move(root),\n    ]);\n\n    return chain([\n      // Add project configuration.\n      updateWorkspace((workspace) => {\n        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n        const project = workspace.projects.get(options.project)!;\n        const buildTarget = project.targets.get('build');\n        const testTarget = project.targets.get('test');\n        if (!buildTarget) {\n          throw new Error(`Build target is not defined for this project.`);\n        }\n\n        const workerConfigPath = join(root, 'tsconfig.worker.json');\n        (buildTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;\n        if (testTarget) {\n          (testTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;\n        }\n      }),\n      // Create the worker in a sibling module.\n      options.snippet ? addSnippet(options) : noop(),\n      // Add the worker.\n      mergeWith(templateSourceWorkerCode),\n      mergeWith(templateSourceWorkerConfig),\n    ]);\n  },\n);\n\nexport default webWorkerSchematic;","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/web-worker/index.ts#L95-L131","documentation":"When adding a web worker, the schematic wires a webWorkerTsConfig option into the project's \"build\" target. If the project has no \"build\" target defined, this Error is thrown since the tsconfig cannot be attached anywhere meaningful.","triggerScenarios":"Running `ng generate web-worker` on a project (after the project lookup succeeds) whose angular.json targets/architect section lacks a \"build\" target — e.g. custom projects, test-only projects, or heavily restructured workspaces.","commonSituations":"Projects assembled manually without the standard application builder targets, monorepo setups where the build target was renamed, or projects migrated where the architect section was trimmed.","solutions":["Add a \"build\" target to the project in angular.json configured with @angular/build:application (or build-angular:application/browser).","Ensure the target is named \"build\" — if you renamed it (e.g. to \"compile\"), rename it back or add an alias target.","After the build target exists, rerun `ng g web-worker <name> --project=<project>` so the worker tsconfig gets wired in."],"exampleFix":"// before (angular.json project)\n\"architect\": { \"test\": { ... } }\n// after\n\"architect\": { \"build\": { \"builder\": \"@angular/build:application\", \"options\": { ... } }, \"test\": { ... } }","handlingStrategy":"validation","validationCode":"const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst p = ws.projects?.[name];\nif (!p?.architect?.build && !p?.targets?.build) {\n  throw new Error(`Project \"${name}\" has no \"build\" target; add @angular/build:application first.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate(['web-worker', workerName, '--project', name]);\n} catch (e) {\n  if (String((e as Error).message).includes('Build target is not defined')) {\n    console.error(`Add a \"build\" target for \"${name}\" in angular.json, then retry.`);\n  } else throw e;\n}","preventionTips":["Keep the standard \"build\" target name in every project's architect section.","Avoid renaming the build target when customizing angular.json.","Scaffold projects with the standard Angular builder set so schematics can find their targets."],"tags":["schematics","web-worker","angular-json"],"backgroundTag":"missing-build-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}