angular/angular-cli · error

RunSchematicTask requires an options object with a non-empty

Error message

RunSchematicTask requires an options object with a non-empty name property.

What it means

The RunSchematicTask executor needs to know which schematic to run. If options is undefined or options.name is falsy, it throws, because the whole task is 'execute schematic <name>'.

Source

Thrown at packages/angular_devkit/schematics/tasks/run-schematic/executor.ts:15

/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.dev/license
 */

import { SchematicContext, TaskExecutor } from '../../src';
import { RunSchematicTaskOptions } from './options';

export default function (): TaskExecutor<RunSchematicTaskOptions<{}>> {
  return (options: RunSchematicTaskOptions<{}> | undefined, context: SchematicContext) => {
    if (!options?.name) {
      throw new Error(
        'RunSchematicTask requires an options object with a non-empty name property.',
      );
    }

    const maybeWorkflow = context.engine.workflow;
    const collection = options.collection || context.schematic.collection.description.name;

    if (!maybeWorkflow) {
      throw new Error('Need Workflow to support executing schematics as post tasks.');
    }

    return maybeWorkflow.execute({
      collection: collection,
      schematic: options.name,
      options: options.options,
      // Allow private when calling from the same collection.
      allowPrivate: collection == context.schematic.collection.description.name,
    });

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Always provide { name: '<schematicName>' } when scheduling the task
  2. Verify the options object is spread after any defaults so name isn't overwritten with undefined
  3. Add a guard/assertion on options.name before addTask
  4. If the name is dynamic, resolve it before scheduling or throw your own descriptive error

Example fix

// before
context.addTask(new RunSchematicTask({ collection: 'my-collection', options: {} })); // no name
// after
context.addTask(new RunSchematicTask({ collection: 'my-collection', name: 'setup', options: {} }));
Defensive patterns

Strategy: validation

Validate before calling

function scheduleRunSchematic(context: SchematicContext, name: string, opts: object = {}) {
  if (!name) throw new Error('RunSchematicTask: name is required');
  context.addTask(new RunSchematicTask({ name, ...opts }));
}

Type guard

function hasName(o: unknown): o is { name: string } {
  return typeof (o as { name?: unknown })?.name === 'string' && (o as { name: string }).name !== '';
}

Try / catch

try {
  context.addTask(new RunSchematicTask(options));
} catch (e) {
  if (/non-empty name property/.test(String(e))) {
    throw new Error(`RunSchematicTask misconfigured: ${JSON.stringify(options)}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Scheduling a RunSchematicTask without options, with an empty name ('' or undefined), or constructing RunSchematicTaskOptions<T> where T doesn't include name and spreading options that shadow it.

Common situations: Custom schematics chaining post-tasks with dynamically computed options where the name variable is undefined; JSON option mismatches; copying task code and forgetting the name field.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/81133a705d06c2b5. Report an issue: GitHub.