{"record":{"id":"8985e730469a1b57","repo":"angular/angular-cli","slug":"schematicname-cannot-be-undefined","errorCode":null,"errorMessage":"schematicName cannot be undefined.","messagePattern":"schematicName cannot be undefined\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/command-builder/schematics-command-module.ts","lineNumber":343,"sourceCode":"\n      return [collectionName, schematicName];\n    }\n\n    return [undefined, schematic];\n  }\n\n  protected async runSchematic(options: {\n    executionOptions: SchematicsExecutionOptions;\n    schematicOptions: OtherOptions;\n    collectionName: string;\n    schematicName: string;\n  }): Promise<number> {\n    const { logger } = this.context;\n    const { schematicOptions, executionOptions, collectionName, schematicName } = options;\n    const workflow = await this.getOrCreateWorkflowForExecution(collectionName, executionOptions);\n\n    if (!schematicName) {\n      throw new Error('schematicName cannot be undefined.');\n    }\n\n    const { unsubscribe, files } = subscribeToWorkflow(workflow, logger);\n\n    try {\n      await workflow\n        .execute({\n          collection: collectionName,\n          schematic: schematicName,\n          options: schematicOptions,\n          logger,\n          allowPrivate: this.allowPrivateSchematics,\n        })\n        .toPromise();\n\n      if (!files.size) {\n        logger.info('Nothing to be done.');\n      }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/schematics-command-module.ts#L325-L361","documentation":"runSchematic executes a schematic workflow and requires a schematicName to know which generator to run. Due to the option parsing/types, schematicName can be undefined at runtime, so it throws this defensive error before executing the workflow.","triggerScenarios":"Invoking a schematic command (e.g. 'ng generate' with a collection but no schematic name, or an internal call where options.schematicName was not populated), e.g. 'ng g @scope/collection' without ':' schematic part.","commonSituations":"Typing 'ng generate' with a collection-only argument; custom tooling calling the schematics command module with incomplete options; alias/shell script passing wrong argument order.","solutions":["Provide both collection and schematic: 'ng g @schematics/angular:component my-comp'","Check the command syntax: schematic name is required, e.g. 'ng g component' or 'ng g pkg:generator'","Fix any custom scripts that pass an incomplete options object to runSchematic","Run 'ng g --help' to see required arguments"],"exampleFix":"// before\nng generate @nguniversal/express-ng\n// after\nng generate @nguniversal/express-ng:app","handlingStrategy":"validation","validationCode":"function assertSchematicArgs(args: string[]): void {\n  if (args.length === 0 || !args[0].includes(':') === false && args.length < 1) {\n    throw new Error('Usage: ng generate [collection:]schematic [options]');\n  }\n}\n// simple check: a schematic name is always present\nif (!schematicName) throw new Error('schematicName is required');","typeGuard":null,"tryCatchPattern":"try {\n  await runSchematic(options);\n} catch (e) {\n  if ((e as Error).message === 'schematicName cannot be undefined.') {\n    throw new Error('Provide a schematic name, e.g. ng g @scope/pkg:schematic');\n  }\n  throw e;\n}","preventionTips":["Always pass collection:schematic form in scripts","Check 'ng g --help' for required positional args","Validate argv before invoking generate programmatically"],"tags":["angular-cli","schematics","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}