angular/angular-cli · error

Package "${packageName}" has an invalid builder schema path:

Error message

Package "${packageName}" has an invalid builder schema path: "${builderName}" --> "${builder.schema}"

What it means

The Angular Architect host resolves a builder's option schema path from its package.json builders entry. This error is thrown when the declared schema path is absolute or escapes the builder package via '..' (after normalization), because schemas must be resolvable relative to within the builder's own package.

Source

Thrown at packages/angular_devkit/architect/node/node-modules-architect-host.ts:207

    // Determine builder implementation path (relative within package only)
    const implementationPath = builder.implementation && path.normalize(builder.implementation);
    if (!implementationPath) {
      throw new Error('Could not find the implementation for builder ' + builderStr);
    }
    if (path.isAbsolute(implementationPath) || implementationPath.startsWith('..')) {
      throw new Error(
        `Package "${packageName}" has an invalid builder implementation path: "${builderName}" --> "${builder.implementation}"`,
      );
    }

    // Determine builder option schema path (relative within package only)
    let schemaPath = builder.schema;
    if (!schemaPath) {
      throw new Error('Could not find the schema for builder ' + builderStr);
    }
    if (path.isAbsolute(schemaPath) || path.normalize(schemaPath).startsWith('..')) {
      throw new Error(
        `Package "${packageName}" has an invalid builder schema path: "${builderName}" --> "${builder.schema}"`,
      );
    }

    // The file could be either a package reference or in the local manifest directory.
    if (schemaPath.startsWith('.')) {
      schemaPath = path.join(buildersManifestDirectory, schemaPath);
    } else {
      const manifestRequire = createRequire(buildersManifestDirectory + '/');
      schemaPath = manifestRequire.resolve(schemaPath);
    }

    const schemaText = readFileSync(schemaPath, 'utf-8');

    return Promise.resolve({
      name: builderStr,
      builderName,
      description: builder['description'],

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Edit the builder's package.json so the schema field is a relative path inside the package, e.g. "schema": "./schema.json"
  2. Verify the schema file actually exists inside the published/packaged builder (files field in package.json)
  3. If escaping is truly needed, publish a wrapper package containing the schema instead

Example fix

// before (builder package.json)
"builders": "builders.json", "schema": "/home/me/shared/schema.json"
// after
"builders": "builders.json", "schema": "./schema.json"
Defensive patterns

Strategy: validation

Validate before calling

const pkg = require(builderPkgJsonPath);
for (const [name, b] of Object.entries(pkg.builders || {})) {
  const s = b.schema;
  if (path.isAbsolute(s) || path.normalize(s).startsWith('..')) {
    throw new Error(`Builder ${name} schema must be a relative in-package path: ${s}`);
  }
}

Type guard

function hasValidSchemaPath(b) {
  return typeof b?.schema === 'string' && b.schema.length > 0 &&
    !path.isAbsolute(b.schema) && !path.normalize(b.schema).startsWith('..');
}

Try / catch

try {
  const info = await host.resolveBuilder('my-pkg:my-builder');
} catch (e) {
  if (e.message.includes('invalid builder schema path')) {
    console.error('Fix the schema path in the builder package.json to a relative in-package path');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling architectHost.resolveBuilder('pkg:builder') where the builder's package.json lists a schema path like '/abs/path/schema.json' or '../../outside/schema.json' (or a path that normalizes to start with '..').

Common situations: Hand-written or misconfigured builder packages with an absolute path in package.json; paths assuming the consumer's working directory; builders migrated between machines/monorepos where a previously-absolute path was hardcoded.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/992fc06d12357f3b. Report an issue: GitHub.