angular/angular-cli · error · UnknownSchematicException

Schematic "${name}" not found in collection "${collection.na

Error message

Schematic "${name}" not found in collection "${collection.name}".

What it means

SchematicEngine.createSchematic looks up the schematic description in the given collection, and if not found there, walks the collection's base (extends) descriptions before giving up. When the name resolves nowhere, UnknownSchematicException is thrown reporting the requested schematic name and the top-level collection that was searched. The engine surfaces the top-level collection in the message because extends chains are an implementation detail of the lookup.

Source

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

    if (schematic) {
      return schematic;
    }

    let collectionDescription = collection.description;
    let description = this._host.createSchematicDescription(name, collection.description);
    if (!description) {
      if (collection.baseDescriptions) {
        for (const base of collection.baseDescriptions) {
          description = this._host.createSchematicDescription(name, base);
          if (description) {
            collectionDescription = base;
            break;
          }
        }
      }
      if (!description) {
        // Report the error for the top level schematic collection
        throw new UnknownSchematicException(name, collection.description);
      }
    }

    if (description.private && !allowPrivate) {
      throw new PrivateSchematicException(name, collection.description);
    }

    const factory = this._host.getSchematicRuleFactory(description, collectionDescription);
    schematic = new SchematicImpl<CollectionT, SchematicT>(description, factory, collection, this);

    schematicMap?.set(name, schematic);

    return schematic;
  }

  listSchematicNames(
    collection: Collection<CollectionT, SchematicT>,
    includeHidden?: boolean,

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Verify the schematic name exists in the target collection's collection.json "schematics" map (or run the equivalent list command, e.g. ng generate --list-schematics).
  2. Correct the name/typo in the createSchematic (or ng generate) call.
  3. Point createSchematic at the collection that actually defines the schematic, or add the schematic entry (name -> factory path) to collection.json.
  4. If the schematic should come from a base collection, add it to this collection's "extends" so the base lookup succeeds.

Example fix

// before
const collection = engine.createCollection('my-collection');
const schematic = collection.createSchematic('componnt'); // typo

// after
const collection = engine.createCollection('my-collection');
const schematic = collection.createSchematic('component');
Defensive patterns

Strategy: validation

Validate before calling

import * as fs from 'fs';
function collectionHasSchematic(collectionJsonPath: string, name: string): boolean {
  const json = JSON.parse(fs.readFileSync(collectionJsonPath, 'utf8'));
  return !!json.schematics && Object.prototype.hasOwnProperty.call(json.schematics, name);
}
if (!collectionHasSchematic('node_modules/my-collection/collection.json', 'component')) {
  throw new Error('Schematic "component" does not exist in my-collection');
}

Type guard

function isKnownSchematic(name: string, collection: { listSchematicNames(includeHidden?: boolean): string[] }): boolean {
  return collection.listSchematicNames(true).includes(name);
}

Try / catch

import { UnknownSchematicException } from '@angular-devkit/schematics';
try {
  const schematic = collection.createSchematic(name);
} catch (e) {
  if (e instanceof UnknownSchematicException) {
    const available = collection.listSchematicNames();
    throw new Error(`Unknown schematic "${name}". Available: ${available.join(', ')}`);
  } else { throw e; }
}

Prevention

When it happens

Trigger: engine.createSchematic(name, collection) where neither the collection nor any of its baseDescriptions exports a schematic named "name" — e.g. calling collection.createSchematic('component-x') when collection.json has no such entry, a mistyped schematic name, or the schematic lives in a different collection than the one passed in.

Common situations: Typos in schematic names when invoking schematics programmatically (ng generate with a wrong name produces the same class of failure); running a schematic from a custom collection that was renamed or removed; passing the wrong Collection object to createSchematic; a collection.json that failed to declare the schematic despite its factory file existing.

Related errors


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