{"record":{"id":"28c09896b6dc43dc","repo":"angular/angular-cli","slug":"invalid-builders-json-builders-key-not-found","errorCode":null,"errorMessage":"Invalid builders.json, builders key not found.","messagePattern":"Invalid builders\\.json, builders key not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/architect/testing/testing-architect-host.ts","lineNumber":53,"sourceCode":"  ): void {\n    this._builderImportMap.set(builderName, builder);\n    this._builderMap.set(builderName, { builderName, description, optionSchema });\n  }\n  async addBuilderFromPackage(packageName: string): Promise<void> {\n    const packageJson = await import(packageName + '/package.json');\n    if (!('builders' in packageJson)) {\n      throw new Error('Invalid package.json, builders key not found.');\n    }\n\n    if (!packageJson.name) {\n      throw new Error('Invalid package name');\n    }\n\n    const builderJsonPath = packageName + '/' + packageJson['builders'];\n    const builderJson = await import(builderJsonPath);\n    const builders = builderJson['builders'];\n    if (!builders) {\n      throw new Error('Invalid builders.json, builders key not found.');\n    }\n\n    for (const builderName of Object.keys(builders)) {\n      const b = builders[builderName];\n      // TODO: remove this check as v1 is not supported anymore.\n      if (!b.implementation) {\n        continue;\n      }\n      const handler = (await import(builderJsonPath + '/../' + b.implementation)).default;\n      const optionsSchema = await import(builderJsonPath + '/../' + b.schema);\n      this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);\n    }\n  }\n  addTarget(target: Target, builderName: string, options: json.JsonObject = {}): void {\n    this._targetMap.set(targetStringFromTarget(target), { builderName, options });\n  }\n\n  async getBuilderNameForTarget(target: Target): Promise<string | null> {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/architect/testing/testing-architect-host.ts#L35-L71","documentation":"addBuilderFromPackage() resolves the file named by the package's 'builders' field (typically builders.json) and expects a top-level 'builders' object mapping builder names to definitions. If that object is missing, the host throws this error.","triggerScenarios":"The package's builders file (packageJson['builders'] path) exists but does not contain a top-level { \"builders\": { ... } } object — e.g. an empty file, wrong file, or a schema mismatched with the architect builder format.","commonSituations":"builders.json accidentally emptied or overwritten; pointing the 'builders' key at a different JSON file; hand-written builders.json using the wrong nesting shape.","solutions":["Ensure builders.json has shape { \"builders\": { \"name\": { \"implementation\": \"...\", \"schema\": \"...\", \"description\": \"...\" } } }.","Check that package.json's 'builders' field points to the correct JSON file path.","Fix typos in the top-level key (must be exactly 'builders')."],"exampleFix":"// before (builders.json)\n{\n  \"my-builder\": { \"implementation\": \"./my-builder.impl\" }\n}\n// after\n{\n  \"builders\": {\n    \"my-builder\": { \"implementation\": \"./my-builder.impl\", \"schema\": \"./schema.json\", \"description\": \"My builder\" }\n  }\n}","handlingStrategy":"validation","validationCode":"const pkg = require(packageName + '/package.json');\nconst builderJson = require(packageName + '/' + pkg.builders);\nif (!builderJson.builders || typeof builderJson.builders !== 'object') {\n  throw new Error(`${packageName}: builders.json lacks top-level builders object`);\n}\nawait architectHost.addBuilderFromPackage(packageName);","typeGuard":"function isValidBuildersJson(json: unknown): json is { builders: Record<string, unknown> } {\n  return typeof json === 'object' && json !== null &&\n    'builders' in json && typeof (json as any).builders === 'object';\n}","tryCatchPattern":"try {\n  await architectHost.addBuilderFromPackage(packageName);\n} catch (e) {\n  if (e.message.includes('Invalid builders.json')) {\n    throw new Error(`Fix ${packageName}/builders.json: must contain a \"builders\" object`);\n  }\n  throw e;\n}","preventionTips":["Follow the official builder schema: { builders: { name: { implementation, schema, description } } }.","Validate builders.json in CI with a JSON schema check.","Keep the package.json 'builders' path pointing at the actual file."],"tags":["angular-devkit","builders","builders-json","configuration"],"backgroundTag":"missing-builders-json-key","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}