{"record":{"id":"e868817fe1b79d08","repo":"angular/angular-cli","slug":"invalid-package-json-builders-key-not-found","errorCode":null,"errorMessage":"Invalid package.json, builders key not found.","messagePattern":"Invalid package\\.json, builders key not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/architect/testing/testing-architect-host.ts","lineNumber":42,"sourceCode":"  constructor(\n    public workspaceRoot = '',\n    public currentDirectory: string = workspaceRoot,\n    private _backendHost: ArchitectHost | null = null,\n  ) {}\n\n  addBuilder(\n    builderName: string,\n    builder: Builder,\n    description = 'Testing only builder.',\n    optionSchema: json.schema.JsonSchema = { type: 'object' },\n  ): 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;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/architect/testing/testing-architect-host.ts#L24-L60","documentation":"TestingArchitectHost.addBuilderFromPackage() imports the package's package.json and expects a 'builders' key pointing at the builders definition file (like builders.json). If the key is absent the package cannot supply builders, so the host throws this error.","triggerScenarios":"Calling architectHost.addBuilderFromPackage(packageName) where the package's package.json has no 'builders' field — e.g. passing an app-only package, a plain library, or a typo'd package name that resolves to the wrong package.","commonSituations":"Testing custom builders and accidentally pointing at the wrong package name; packages authored without a builders entry (older schematics-only packages); scoped name typos like '@myorg/builders' vs '@myorg/builders-x'.","solutions":["Verify the package's package.json contains \"builders\": \"./builders.json\" (or similar path).","Add a builders key and a valid builders.json if you own the package.","Check the package name for typos and confirm it is a builder (not schematic-only) package."],"exampleFix":"// before (package.json)\n{ \"name\": \"@myorg/builders\" }\n// after\n{ \"name\": \"@myorg/builders\", \"builders\": \"./builders.json\" }","handlingStrategy":"validation","validationCode":"const pkg = require(packageName + '/package.json');\nif (!('builders' in pkg)) {\n  throw new Error(`${packageName} does not export a builders key`);\n}\nawait architectHost.addBuilderFromPackage(packageName);","typeGuard":"function hasBuildersKey(pkg: object): pkg is { builders: string } {\n  return 'builders' in pkg && typeof (pkg as any).builders === 'string';\n}","tryCatchPattern":"try {\n  await architectHost.addBuilderFromPackage(packageName);\n} catch (e) {\n  if (e.message.includes('builders key not found')) {\n    throw new Error(`Package ${packageName} is not a builder package`);\n  }\n  throw e;\n}","preventionTips":["Verify 'builders' exists in the target package's package.json before registering.","Add a package.json lint/check in CI for your builder packages.","Double-check scoped package names for typos."],"tags":["angular-devkit","builders","package-json","configuration"],"backgroundTag":"missing-package-json-key","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}