angular/angular-cli · error · SchematicNameCollisionException

Schematics/alias ${JSON.stringify(alias)} collides with anot

Error message

Schematics/alias ${JSON.stringify(alias)} collides with another alias or schematic name.

What it means

Thrown by createCollectionDescription while loading a collection.json. The collection declares an alias for a schematic that collides with another schematic's name (or a previously seen alias) in the same collection. The Angular Devkit refuses ambiguous names because calling a schematic by that identifier would be nondeterministic.

Source

Thrown at packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts:188

      jsonValue['extends'] = [jsonValue['extends']];
    }

    const description = this._transformCollectionDescription(name, {
      ...jsonValue,
      path,
    });
    if (!description || !description.name) {
      throw new InvalidCollectionJsonException(name, path);
    }

    // Validate aliases.
    const allNames = Object.keys(description.schematics);
    for (const schematicName of Object.keys(description.schematics)) {
      const aliases = description.schematics[schematicName].aliases || [];

      for (const alias of aliases) {
        if (allNames.indexOf(alias) != -1) {
          throw new SchematicNameCollisionException(alias);
        }
      }

      allNames.push(...aliases);
    }

    return description;
  }

  createSchematicDescription(
    name: string,
    collection: FileSystemCollectionDesc,
  ): FileSystemSchematicDesc | null {
    // Resolve aliases first.
    for (const schematicName of Object.keys(collection.schematics)) {
      const schematicDescription = collection.schematics[schematicName];
      if (schematicDescription.aliases && schematicDescription.aliases.indexOf(name) != -1) {
        name = schematicName;

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Open the collection.json referenced by the error and list all schematic names and aliases.
  2. Find the alias that duplicates a schematic name or another alias and remove or rename it.
  3. Re-run the command that loads the collection to confirm the collision is gone.

Example fix

// before (collection.json)
"schematics": {
  "component": { "factory": "./component", "aliases": ["c", "service"] },
  "service": { "factory": "./service" }
}
// after
"schematics": {
  "component": { "factory": "./component", "aliases": ["c"] },
  "service": { "factory": "./service" }
}
Defensive patterns

Strategy: validation

Validate before calling

const coll = JSON.parse(readFileSync('collection.json', 'utf8'));
const names = Object.keys(coll.schematics);
for (const [name, s] of Object.entries(coll.schematics)) {
  for (const alias of s.aliases || []) {
    if (names.includes(alias)) throw new Error(`Alias '${alias}' of '${name}' collides with a schematic name`);
  }
}

Try / catch

try {
  engine.createCollection('./collection.json');
} catch (e) {
  if (e instanceof SchematicNameCollisionException) {
    console.error(`Rename the alias '${e.message.match(/"(.*)"/)?.[1]}' in collection.json`);
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: A collection.json has schematic X with aliases containing a string that equals another schematic's name in the same collection, or two schematics share an alias. Raised inside the `for (const alias of aliases)` loop when `allNames.indexOf(alias) != -1`.

Common situations: Hand-editing collection.json and adding an alias that matches an existing schematic name; copy-pasting schematic entries and forgetting to change aliases; merging two schematics into one collection without deduplicating names; renaming a schematic but leaving its old name as an alias while another schematic already uses that name.

Related errors


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