angular/angular-cli · error · CollectionMissingSchematicsMapException

Collection "${name}" does not have a schematics map.

Error message

Collection "${name}" does not have a schematics map.

What it means

Thrown by _transformCollectionDescription in packages/angular_devkit/schematics/tools/node-module-engine-host.ts:123 when the loaded collection description has no "schematics" property or that property is not an object. A collection JSON file must contain a schematics map (schematic name -> description) for the engine to expose any schematics; this guard rejects malformed collection files via CollectionMissingSchematicsMapException.

Source

Thrown at packages/angular_devkit/schematics/tools/node-module-engine-host.ts:123

  protected _resolveReferenceString(
    refString: string,
    parentPath: string,
    collectionDescription?: FileSystemCollectionDesc,
  ): { ref: RuleFactory<{}>; path: string } | null {
    const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
    if (!ref.ref) {
      return null;
    }

    return { ref: ref.ref, path: ref.module };
  }

  protected _transformCollectionDescription(
    name: string,
    desc: Partial<FileSystemCollectionDesc>,
  ): FileSystemCollectionDesc {
    if (!desc.schematics || typeof desc.schematics != 'object') {
      throw new CollectionMissingSchematicsMapException(name);
    }

    return {
      ...desc,
      name,
    } as FileSystemCollectionDesc;
  }

  protected _transformSchematicDescription(
    name: string,
    _collection: FileSystemCollectionDesc,
    desc: Partial<FileSystemSchematicDesc>,
  ): FileSystemSchematicDesc {
    if (!desc.factoryFn || !desc.path || !desc.description) {
      throw new SchematicMissingFieldsException(name);
    }

    return desc as FileSystemSchematicDesc;

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Open the collection JSON referenced by the package's "schematics" field and add a top-level "schematics": { ... } object mapping schematic names to their descriptions.
  2. Confirm the "schematics" field in package.json points to the collection.json, not to a schema.json or tsconfig-style file.
  3. Check the build/publish pipeline isn't overwriting or emptying the collection file (e.g. copying the wrong file into dist).
  4. Reinstall/upgrade the package in case your local copy is stale or corrupted.

Example fix

// before (collection.json)
{
  "schematic": {
    "my-schematic": { "factory": "./my-schematic" }
  }
}
// after
{
  "schematics": {
    "my-schematic": { "factory": "./my-schematic", "description": "Generates a thing" }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

function validateCollectionJson(collectionJson) {
  const desc = JSON.parse(collectionJson);
  if (!desc.schematics || typeof desc.schematics !== 'object' || Array.isArray(desc.schematics)) {
    throw new Error('collection JSON must have a top-level "schematics" object');
  }
  return desc;
}

Type guard

function hasSchematicsMap(desc) {
  return typeof desc === 'object' && desc !== null
    && typeof desc.schematics === 'object' && desc.schematics !== null
    && !Array.isArray(desc.schematics);
}

Try / catch

try {
  const collection = engine.createCollection(name);
} catch (err) {
  if (err instanceof CollectionMissingSchematicsMapException) {
    console.error(`Collection "${name}" JSON lacks a "schematics" map; fix collection.json`);
  } else { throw err; }
}

Prevention

When it happens

Trigger: Loading a collection JSON whose top-level object is missing "schematics" or has it set to a string/array/null — e.g. the package's "schematics" field in package.json points to a JSON file that only contains metadata, or an empty `{}` collection file, or a hand-edited collection.json that dropped the schematics key.

Common situations: Pointing package.json's "schematics" field at the wrong JSON file (e.g. a schema file instead of the collection file); publishing a collection file truncated/emptied by a build step; typos like "schematic" or "schemas" as the top-level key; upgrading a schematics package whose collection format changed.

Related errors


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