angular/angular-cli · error · UnknownCollectionException

Unknown collection "${name}".

Error message

Unknown collection "${name}".

What it means

When the engine builds a collection description it delegates to the host's createCollectionDescription; if the host cannot resolve the named collection it returns null and the engine throws UnknownCollectionException. Collections are resolved through registered collection hosts (e.g. node modules with a collection.json), so the name must match an installed, registered collection.

Source

Thrown at packages/angular_devkit/schematics/src/engine/engine.ts:218

    }

    const [description, bases] = this._createCollectionDescription(name, requester?.description);

    collection = new CollectionImpl<CollectionT, SchematicT>(description, this, bases);
    this._collectionCache.set(name, collection);
    this._schematicCache.set(collection, new Map());

    return collection;
  }

  private _createCollectionDescription(
    name: string,
    requester?: CollectionDescription<CollectionT>,
    parentNames?: Set<string>,
  ): [CollectionDescription<CollectionT>, Array<CollectionDescription<CollectionT>>] {
    const description = this._host.createCollectionDescription(name, requester);
    if (!description) {
      throw new UnknownCollectionException(name);
    }
    if (parentNames && parentNames.has(description.name)) {
      throw new CircularCollectionException(name);
    }

    const bases = new Array<CollectionDescription<CollectionT>>();
    if (description.extends) {
      parentNames = (parentNames || new Set<string>()).add(description.name);
      for (const baseName of description.extends) {
        const [base, baseBases] = this._createCollectionDescription(
          baseName,
          description,
          new Set(parentNames),
        );

        bases.unshift(base, ...baseBases);
      }
    }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Install the collection package (e.g. `npm install --save-dev @schematics/angular`) and verify the exact name
  2. Check the package's package.json `schematics` field points at its collection.json
  3. Verify the custom collection host registers the collection before engine.execute
  4. Pin versions consistent with your Angular CLI to avoid renamed/moved collections

Example fix

// before
engine.createCollection('@angular/cdk/schematics'); // wrong name
// after
engine.createCollection('@angular/cdk'); // valid collection name, installed package
Defensive patterns

Strategy: try-catch

Validate before calling

const name = '@schematics/angular';
try {
  require.resolve(`${name}/collection.json`);
} catch {
  throw new Error(`Collection "${name}" is not installed; run npm install --save-dev ${name}.`);
}

Try / catch

import { UnknownCollectionException } from '@angular-devkit/schematics';
try {
  engine.createCollection(name);
} catch (err) {
  if (err instanceof UnknownCollectionException) {
    console.error(`Collection "${name}" not found. Is the package installed and its collection.json resolvable?`);
  } else throw err;
}

Prevention

When it happens

Trigger: executeSchematic / createCollection called with a collection name that no registered host can resolve — wrong name string, collection package not installed, or its collection.json missing/not exported by its package.json `schematics` field.

Common situations: Running `ng generate` with a mistyped or uninstalled schematic collection; a devDependency missing in CI; a renamed package between versions; referencing `@schematics/angular` variants that aren't installed in a bare project.

Related errors


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