angular/angular-cli · error
Invalid package.json, builders key not found.
Error message
Invalid package.json, builders key not found.
What it means
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.
Source
Thrown at packages/angular_devkit/architect/testing/testing-architect-host.ts:42
constructor(
public workspaceRoot = '',
public currentDirectory: string = workspaceRoot,
private _backendHost: ArchitectHost | null = null,
) {}
addBuilder(
builderName: string,
builder: Builder,
description = 'Testing only builder.',
optionSchema: json.schema.JsonSchema = { type: 'object' },
): void {
this._builderImportMap.set(builderName, builder);
this._builderMap.set(builderName, { builderName, description, optionSchema });
}
async addBuilderFromPackage(packageName: string): Promise<void> {
const packageJson = await import(packageName + '/package.json');
if (!('builders' in packageJson)) {
throw new Error('Invalid package.json, builders key not found.');
}
if (!packageJson.name) {
throw new Error('Invalid package name');
}
const builderJsonPath = packageName + '/' + packageJson['builders'];
const builderJson = await import(builderJsonPath);
const builders = builderJson['builders'];
if (!builders) {
throw new Error('Invalid builders.json, builders key not found.');
}
for (const builderName of Object.keys(builders)) {
const b = builders[builderName];
// TODO: remove this check as v1 is not supported anymore.
if (!b.implementation) {
continue;View on GitHub (pinned to bb72145f9a)
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.
Example fix
// before (package.json)
{ "name": "@myorg/builders" }
// after
{ "name": "@myorg/builders", "builders": "./builders.json" } Defensive patterns
Strategy: validation
Validate before calling
const pkg = require(packageName + '/package.json');
if (!('builders' in pkg)) {
throw new Error(`${packageName} does not export a builders key`);
}
await architectHost.addBuilderFromPackage(packageName); Type guard
function hasBuildersKey(pkg: object): pkg is { builders: string } {
return 'builders' in pkg && typeof (pkg as any).builders === 'string';
} Try / catch
try {
await architectHost.addBuilderFromPackage(packageName);
} catch (e) {
if (e.message.includes('builders key not found')) {
throw new Error(`Package ${packageName} is not a builder package`);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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'.
Related errors
- Invalid package name
- Invalid builders.json, builders key not found.
- Package ${JSON.stringify(name)} was found but does not suppo
- No project name provided and no default project found in wor
- Package ${JSON.stringify(name)} was not found in package.jso
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/e868817fe1b79d08.
Report an issue: GitHub.