angular/angular-cli · warning

Option '${key}' has been specified multiple times. The value

Error message

Option '${key}' has been specified multiple times. The value '${newValue}' will be used.

What it means

The normalize-options middleware warns when a CLI option receives an array of values but is not declared as an array option, meaning it was specified multiple times on the command line. yargs accumulates repeated flags into arrays; the middleware pops the last value, keeps it, and warns that earlier values are discarded.

Source

Thrown at packages/angular/cli/src/command-builder/utilities/normalize-options-middleware.ts:32

 * By default, when an option is non array and it is provided multiple times in the command line, yargs
 * will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.
 * But this option also have an effect on real array options which isn't desired.
 *
 * See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614
 */
export function createNormalizeOptionsMiddleware(localeYargs: Argv): (args: Arguments) => void {
  return (args: Arguments) => {
    // `getOptions` is not included in the types even though it's public API.
    // https://github.com/yargs/yargs/issues/2098
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    const { array } = (localeYargs as any).getOptions();
    const arrayOptions = new Set(array);

    for (const [key, value] of Object.entries(args)) {
      if (key !== '_' && Array.isArray(value) && !arrayOptions.has(key)) {
        const newValue = value.pop();
        // eslint-disable-next-line no-console
        console.warn(
          `Option '${key}' has been specified multiple times. The value '${newValue}' will be used.`,
        );
        args[key] = newValue;
      }
    }
  };
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Remove the duplicate option and keep a single value: `ng build --configuration production`.
  2. If multiple values are intended, check whether the target builder/schematic supports an array option for that flag.
  3. Audit npm scripts / CI configs that concatenate flags to avoid duplication.

Example fix

// before
ng build --configuration production --configuration staging
// after
ng build --configuration staging
Defensive patterns

Strategy: validation

Validate before calling

const flags = process.argv.slice(2);
const seen = new Set();
for (const f of flags) {
  if (f.startsWith('--')) {
    const k = f.split('=')[0];
    if (seen.has(k)) console.warn(`Duplicate option ${k}; last value wins.`);
    seen.add(k);
  }
}

Prevention

When it happens

Trigger: Passing the same scalar option more than once, e.g. `ng build --configuration production --configuration development`, where 'configuration' is not an array-typed option.

Common situations: Shell scripts or npm scripts appending duplicate flags; copy-pasted build commands with conflicting --configuration values; CI matrices concatenating option strings twice.

Related errors


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