angular/angular-cli · error · OptionIsNotDefinedException

Option "${name}" is not defined.

Error message

Option "${name}" is not defined.

What it means

Same family as error 246 but for piped placeholders: after splitting a match on options.pipeSeparator, the base name's value resolved to undefined in data, so OptionIsNotDefinedException(name) is thrown. Every piped placeholder's base name must exist in the template data.

Source

Thrown at packages/angular_devkit/schematics/src/rules/template.ts:126

      if (!options.pipeSeparator) {
        if (typeof replacement == 'function') {
          replacement = replacement.call(data, original);
        }

        if (replacement === undefined) {
          throw new OptionIsNotDefinedException(match);
        }
      } else {
        const [name, ...pipes] = match.split(options.pipeSeparator);
        replacement = data[name];

        if (typeof replacement == 'function') {
          replacement = replacement.call(data, original);
        }

        if (replacement === undefined) {
          throw new OptionIsNotDefinedException(name);
        }

        replacement = pipes.reduce((acc: string, pipe: string) => {
          if (!pipe) {
            return acc;
          }
          if (!(pipe in data)) {
            throw new UnknownPipeException(pipe);
          }
          const pipeFn = data[pipe];
          if (typeof pipeFn != 'function') {
            throw new InvalidPipeException(pipe);
          }

          // Coerce to string.
          return '' + pipeFn(acc);
        }, '' + replacement);
      }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Ensure the base key exists in applyTemplates data, e.g. applyTemplates({ name: options.name, dasherize: string.dasherize }).
  2. Fix the base placeholder name spelling in the template file path.
  3. Guard the value before applying: provide fallbacks in the options object.

Example fix

// before
applyTemplates({ dasherize }) // 'name' missing
// after
applyTemplates({ name: options.name, dasherize })
Defensive patterns

Strategy: validation

Validate before calling

const base = match.split(options.pipeSeparator!)[0];
if (!(base in data)) {
  throw new Error(`Base option "${base}" must be provided to template()`);
}

Type guard

function hasBaseOption(data: Record<string, unknown>, base: string): boolean {
  return data[base] !== undefined;
}

Try / catch

try {
  return mergeWith(apply(source, [template(options)]));
} catch (err) {
  if (err instanceof OptionIsNotDefinedException) {
    console.error(`Provide base value for piped placeholder: ${err.message}`);
  }
}

Prevention

When it happens

Trigger: Path like '__name@dasherize__' with pipeSeparator '@' where data['name'] is undefined (or a function returning undefined before piping).

Common situations: Forgetting to pass the base option when only the piped form is used; typo in the base name inside a piped placeholder; applyTemplates called with the wrong options object.

Related errors


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