{"record":{"id":"937d44ad549891cd","repo":"angular/angular-cli","slug":"schematics-alias-json-stringify-alias-collides","errorCode":null,"errorMessage":"Schematics/alias ${JSON.stringify(alias)} collides with another alias or schematic name.","messagePattern":"Schematics/alias (.+?) collides with another alias or schematic name\\.","errorType":"exception","errorClass":"SchematicNameCollisionException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts","lineNumber":188,"sourceCode":"      jsonValue['extends'] = [jsonValue['extends']];\n    }\n\n    const description = this._transformCollectionDescription(name, {\n      ...jsonValue,\n      path,\n    });\n    if (!description || !description.name) {\n      throw new InvalidCollectionJsonException(name, path);\n    }\n\n    // Validate aliases.\n    const allNames = Object.keys(description.schematics);\n    for (const schematicName of Object.keys(description.schematics)) {\n      const aliases = description.schematics[schematicName].aliases || [];\n\n      for (const alias of aliases) {\n        if (allNames.indexOf(alias) != -1) {\n          throw new SchematicNameCollisionException(alias);\n        }\n      }\n\n      allNames.push(...aliases);\n    }\n\n    return description;\n  }\n\n  createSchematicDescription(\n    name: string,\n    collection: FileSystemCollectionDesc,\n  ): FileSystemSchematicDesc | null {\n    // Resolve aliases first.\n    for (const schematicName of Object.keys(collection.schematics)) {\n      const schematicDescription = collection.schematics[schematicName];\n      if (schematicDescription.aliases && schematicDescription.aliases.indexOf(name) != -1) {\n        name = schematicName;","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts#L170-L206","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","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."],"exampleFix":"// before (collection.json)\n\"schematics\": {\n  \"component\": { \"factory\": \"./component\", \"aliases\": [\"c\", \"service\"] },\n  \"service\": { \"factory\": \"./service\" }\n}\n// after\n\"schematics\": {\n  \"component\": { \"factory\": \"./component\", \"aliases\": [\"c\"] },\n  \"service\": { \"factory\": \"./service\" }\n}","handlingStrategy":"validation","validationCode":"const coll = JSON.parse(readFileSync('collection.json', 'utf8'));\nconst names = Object.keys(coll.schematics);\nfor (const [name, s] of Object.entries(coll.schematics)) {\n  for (const alias of s.aliases || []) {\n    if (names.includes(alias)) throw new Error(`Alias '${alias}' of '${name}' collides with a schematic name`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  engine.createCollection('./collection.json');\n} catch (e) {\n  if (e instanceof SchematicNameCollisionException) {\n    console.error(`Rename the alias '${e.message.match(/\"(.*)\"/)?.[1]}' in collection.json`);\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["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."],"tags":["schematics","configuration","naming-collision"],"backgroundTag":"schematic-name-collision","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}