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 after a collection.json is loaded: the parsed JSON either has no `schematics` key or it is not an object. A valid collection must map schematic names to their descriptions.
Source
Thrown at packages/angular_devkit/schematics/tools/file-system-engine-host.ts:69
protected _resolveReferenceString(
refString: string,
parentPath: string,
): { ref: RuleFactory<{}>; path: string } | null {
// Use the same kind of export strings as NodeModule.
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
- Add a `schematics` object to collection.json with at least one schematic entry.
- Validate the JSON parses and `schematics` is a plain object (not null/array).
- Confirm you are pointing the engine at collection.json, not package.json.
Example fix
// before (collection.json)
{ "$schema": "...", "version": "1.0" }
// after
{ "$schema": "...", "version": "1.0", "schematics": { "my-schematic": { "factory": "./index#run", "description": "Runs it" } } } Defensive patterns
Strategy: validation
Validate before calling
const coll = JSON.parse(readFileSync('collection.json', 'utf8'));
if (!coll.schematics || typeof coll.schematics !== 'object' || Array.isArray(coll.schematics)) {
throw new Error('collection.json must contain a "schematics" object');
} Type guard
function hasSchematicsMap(c: unknown): c is { schematics: Record<string, unknown> } {
return typeof c === 'object' && c !== null && typeof (c as any).schematics === 'object' && (c as any).schematics !== null && !Array.isArray((c as any).schematics);
} Try / catch
try {
const collection = engine.createCollection(name);
} catch (e) {
if (String(e.message).includes('does not have a schematics map')) {
throw new Error(`Add a "schematics" map to ${name}'s collection.json`);
}
throw e;
} Prevention
- Start every collection.json from the official $schema and keep the schematics map present.
- Validate collection.json in CI against the schematics collection JSON schema.
- Never point the engine at package.json; only collection.json has the schematics map.
When it happens
Trigger: createCollection loads a collection.json that lacks a top-level `schematics` object (missing, null, an array, or a string).
Common situations: A collection.json scaffolded with only `version` or `name` fields; a JSON file that is actually a package.json by mistake; a hand-edited file where `schematics` was renamed or deleted; trailing structural changes from a bad merge.
Related errors
- Collection JSON at path ${JSON.stringify(path)} is invalid.
- Option "project" is required.
- Project is not defined in this workspace.
- Targets are not defined for this project.
- Invalid file replacement: ${JSON.stringify(fileReplacement)}
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/10423865856a38df.
Report an issue: GitHub.