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
- Always provide { name: '<schematicName>' } when scheduling the task
- Verify the options object is spread after any defaults so name isn't overwritten with undefined
- Add a guard/assertion on options.name before addTask
- 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
- Always set name when constructing RunSchematicTaskOptions
- Spread defaults before dynamic fields so name can't be clobbered by undefined
- Add a small wrapper helper that enforces the name parameter
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
- Schematic input does not validate against the Schema: ${JSON
- Option "project" is required.
- Project is not defined in this workspace.
- Targets are not defined for this project.
- Invalid redirect status code: ${status}. Please use one of t
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/81133a705d06c2b5.
Report an issue: GitHub.