angular/angular-cli · error · SchematicsException

name option is required.

Error message

name option is required.

What it means

The blank schematic requires the 'name' option to decide what to generate (a new schematic within an existing collection, or a full project). If options.name is falsy when the rule executes, it throws this SchematicsException. This is fail-fast validation so the schematic never produces partial or wrong output.

Source

Thrown at packages/angular_devkit/schematics_cli/blank/factory.ts:49

    const collectionJson = tree.readJson(collectionPath);

    if (!isJsonObject(collectionJson) || !isJsonObject(collectionJson.schematics)) {
      throw new Error('Invalid collection.json; schematics needs to be an object.');
    }

    collectionJson['schematics'][schematicName] = description;
    tree.overwrite(collectionPath, JSON.stringify(collectionJson, undefined, 2));
  };
}

export default function (options: Schema): Rule {
  const schematicsVersion = require('@angular-devkit/schematics/package.json').version;
  const coreVersion = require('@angular-devkit/core/package.json').version;

  // Verify if we need to create a full project, or just add a new schematic.
  return (tree: Tree, context: SchematicContext) => {
    if (!options.name) {
      throw new SchematicsException('name option is required.');
    }

    let collectionPath: Path | undefined;
    try {
      const packageJson = tree.readJson('/package.json') as {
        schematics: unknown;
      };
      if (typeof packageJson.schematics === 'string') {
        const p = normalize(packageJson.schematics);
        if (tree.exists(p)) {
          collectionPath = p;
        }
      }
    } catch {}

    let source = apply(url('./schematic-files'), [
      applyTemplates({
        ...options,

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Rerun the command with a name: e.g. `ng g blank --name=my-schematic` or `schematics @schematics/schematics:blank --name=my-schematic`.
  2. Check your npm script / CI invocation to confirm the --name value is actually forwarded (not swallowed by quoting or an unset shell variable).
  3. Ensure the flag is spelled exactly `--name`; unknown/misspelled flags are ignored rather than mapped to options.name.

Example fix

// before
npx schematics @schematics/schematics:blank --dry-run

// after
npx schematics @schematics/schematics:blank --name=my-schematic
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2);
const nameFlagIdx = args.findIndex(a => a === '--name' || a.startsWith('--name='));
const name = nameFlagIdx === -1 ? undefined : args[nameFlagIdx].includes('=') ? args[nameFlagIdx].split('=')[1] : args[nameFlagIdx + 1];
if (!name) {
  throw new Error('Provide --name before running the blank schematic.');
}

Type guard

function hasName(o) {
  return typeof o === 'object' && o !== null && typeof o.name === 'string' && o.name.length > 0;
}

Try / catch

try {
  await schematicRunner.executeBlank({ name: 'my-schematic' });
} catch (err) {
  if (err.message === 'name option is required.') {
    console.error('Missing --name; rerun with e.g. --name=my-schematic');
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: Invoking the blank schematic (e.g. `ng g blank` or the schematics CLI `schematics ...:blank`) without passing --name, or passing --name="" (empty string is falsy and also triggers the throw).

Common situations: Running the schematic from a script or npm task that forgot to forward the name argument; interactive prompting disabled in CI; typo in the flag name so it lands in extraOptions instead of options.name; copying a doc example that omitted --name.

Related errors


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