{"record":{"id":"fbb4a4e9713913d6","repo":"angular/angular-cli","slug":"option-key-has-been-specified-multiple-times","errorCode":null,"errorMessage":"Option '${key}' has been specified multiple times. The value '${newValue}' will be used.","messagePattern":"Option '(.+?)' has been specified multiple times\\. The value '(.+?)' will be used\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/command-builder/utilities/normalize-options-middleware.ts","lineNumber":32,"sourceCode":" * By default, when an option is non array and it is provided multiple times in the command line, yargs\n * will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.\n * But this option also have an effect on real array options which isn't desired.\n *\n * See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614\n */\nexport function createNormalizeOptionsMiddleware(localeYargs: Argv): (args: Arguments) => void {\n  return (args: Arguments) => {\n    // `getOptions` is not included in the types even though it's public API.\n    // https://github.com/yargs/yargs/issues/2098\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    const { array } = (localeYargs as any).getOptions();\n    const arrayOptions = new Set(array);\n\n    for (const [key, value] of Object.entries(args)) {\n      if (key !== '_' && Array.isArray(value) && !arrayOptions.has(key)) {\n        const newValue = value.pop();\n        // eslint-disable-next-line no-console\n        console.warn(\n          `Option '${key}' has been specified multiple times. The value '${newValue}' will be used.`,\n        );\n        args[key] = newValue;\n      }\n    }\n  };\n}\n","sourceCodeStart":14,"sourceCodeEnd":40,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/utilities/normalize-options-middleware.ts#L14-L40","documentation":"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.","triggerScenarios":"Passing the same scalar option more than once, e.g. `ng build --configuration production --configuration development`, where 'configuration' is not an array-typed option.","commonSituations":"Shell scripts or npm scripts appending duplicate flags; copy-pasted build commands with conflicting --configuration values; CI matrices concatenating option strings twice.","solutions":["Remove the duplicate option and keep a single value: `ng build --configuration production`.","If multiple values are intended, check whether the target builder/schematic supports an array option for that flag.","Audit npm scripts / CI configs that concatenate flags to avoid duplication."],"exampleFix":"// before\nng build --configuration production --configuration staging\n// after\nng build --configuration staging","handlingStrategy":"validation","validationCode":"const flags = process.argv.slice(2);\nconst seen = new Set();\nfor (const f of flags) {\n  if (f.startsWith('--')) {\n    const k = f.split('=')[0];\n    if (seen.has(k)) console.warn(`Duplicate option ${k}; last value wins.`);\n    seen.add(k);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate flags in npm scripts and CI command construction.","Prefer setting --configuration once via a variable instead of concatenating fragments."],"tags":["angular-cli","cli-options","duplicate-flags","yargs"],"backgroundTag":"duplicate-cli-option","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}