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
- Open the collection.json referenced by the error and list all schematic names and aliases.
- Find the alias that duplicates a schematic name or another alias and remove or rename it.
- 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
- Keep a single source of truth for schematic names and aliases; lint collection.json in CI.
- Never use another schematic's name as an alias; prefix aliases uniquely (e.g. short forms only).
- Automate collection.json generation from schematic metadata instead of hand-editing.
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
- Option "project" is required.
- Project is not defined in this workspace.
- Targets are not defined for this project.
- Circular collection reference "${name}".
- Unregistered task "${name}"${addendum}.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/937d44ad549891cd.
Report an issue: GitHub.