{"record":{"id":"6bd36d843c992ec6","repo":"angular/angular-cli","slug":"schematic-json-stringify-name-is-missing-a-fac","errorCode":null,"errorMessage":"Schematic ${JSON.stringify(name)} is missing a factory.","messagePattern":"Schematic (.+?) is missing a factory\\.","errorType":"exception","errorClass":"SchematicMissingFactoryException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts","lineNumber":238,"sourceCode":"\n    if (partialDesc.extends) {\n      const index = partialDesc.extends.indexOf(':');\n      const collectionName = index !== -1 ? partialDesc.extends.slice(0, index) : null;\n      const schematicName =\n        index === -1 ? partialDesc.extends : partialDesc.extends.slice(index + 1);\n\n      if (collectionName !== null) {\n        const extendCollection = this.createCollectionDescription(collectionName);\n\n        return this.createSchematicDescription(schematicName, extendCollection);\n      } else {\n        return this.createSchematicDescription(schematicName, collection);\n      }\n    }\n    // Use any on this ref as we don't have the OptionT here, but we don't need it (we only need\n    // the path).\n    if (!partialDesc.factory) {\n      throw new SchematicMissingFactoryException(name);\n    }\n    const resolvedRef = this._resolveReferenceString(\n      partialDesc.factory,\n      collectionPath,\n      collection,\n    );\n    if (!resolvedRef) {\n      throw new FactoryCannotBeResolvedException(name);\n    }\n\n    let schema = partialDesc.schema;\n    let schemaJson: JsonObject | undefined = undefined;\n    if (schema) {\n      if (!isAbsolute(schema)) {\n        schema = join(collectionPath, schema);\n      }\n      schemaJson = readJsonFile(schema) as JsonObject;\n    }","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts#L220-L256","documentation":"Thrown by createSchematicDescription when the schematic entry in collection.json has no `factory` property. A schematic must point to a factory function; without one the engine cannot instantiate it.","triggerScenarios":"A collection.json schematic entry omits `factory` (or it is null/undefined), so `if (!partialDesc.factory)` fires after resolving aliases/references.","commonSituations":"Hand-writing a custom collection and forgetting the factory field; a typo like `factories` or `factoryFn` in collection.json; a schematic entry that only sets aliases/schema; upgrading from a generator whose collection format differed.","solutions":["Open collection.json and add the missing `factory` field pointing to the compiled JS file and export, e.g. \"./component/index#myComponentGenerator\".","Verify the path/export exists relative to the collection root and is compiled if written in TypeScript.","Reload the collection to confirm."],"exampleFix":"// before (collection.json)\n\"my-schematic\": { \"description\": \"does stuff\", \"schema\": \"./schema.json\" }\n// after\n\"my-schematic\": { \"factory\": \"./my-schematic/index#mySchematic\", \"description\": \"does stuff\", \"schema\": \"./schema.json\" }","handlingStrategy":"validation","validationCode":"const coll = JSON.parse(readFileSync('collection.json', 'utf8'));\nfor (const [name, s] of Object.entries(coll.schematics)) {\n  if (!s.factory) throw new Error(`Schematic '${name}' has no factory`);\n}","typeGuard":"function hasFactory(s: unknown): s is { factory: string } {\n  return typeof s === 'object' && s !== null && typeof (s as any).factory === 'string' && (s as any).factory.length > 0;\n}","tryCatchPattern":"try {\n  return engine.createSchematic(name, collection);\n} catch (e) {\n  if (String(e.message).includes('is missing a factory')) {\n    throw new Error(`Add a \"factory\" field to schematic '${name}' in collection.json`);\n  }\n  throw e;\n}","preventionTips":["Validate collection.json against the @angular-devkit/schematics collection JSON schema in CI.","Scaffold new schematic entries from a template that always includes factory/description/schema.","Add a unit test that loads the collection through createCollection to catch declaration errors early."],"tags":["schematics","configuration","missing-field"],"backgroundTag":"missing-factory-declaration","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}