{"record":{"id":"9e7c99540efb9e70","repo":"mochajs/mocha","slug":"err-mocha-unsupported-9e7c99","errorCode":"ERR_MOCHA_UNSUPPORTED","errorMessage":"Arguments ${oneAndDoneOptions.join(\" and \")} are mutually exclusive","messagePattern":"Arguments (.+?) are mutually exclusive","errorType":"exception","errorClass":"UnsupportedError","httpStatus":null,"severity":"error","filePath":"lib/cli/run.cjs","lineNumber":78,"sourceCode":"      const normalizedName = camelCase(name);\n      if (!(normalizedName in argv)) {\n        argv[normalizedName] = argv[name];\n      }\n    }\n  });\n\n  if (Array.isArray(argv[\"reporter-option\"])) {\n    argv[\"reporter-option\"] = coerceReporterOption(argv[\"reporter-option\"]);\n  }\n};\n\nconst validateRunOptions = (argv) => {\n  // \"one-and-dones\"; help and version are handled by the top-level CLI.\n  const oneAndDoneOptions = Object.keys(ONE_AND_DONES).filter((opt) =>\n    Boolean(argv[opt]),\n  );\n  if (oneAndDoneOptions.length > 1) {\n    throw createUnsupportedError(\n      `Arguments ${oneAndDoneOptions.join(\" and \")} are mutually exclusive`,\n    );\n  }\n\n  Object.keys(ONE_AND_DONES).forEach((opt) => {\n    if (argv[opt]) {\n      ONE_AND_DONES[opt].call(null);\n      process.exit(0);\n    }\n  });\n\n  if (argv.invert && !(\"fgrep\" in argv || \"grep\" in argv)) {\n    throw createMissingArgumentError(\n      '\"--invert\" requires one of \"--fgrep <str>\" or \"--grep <regexp>\"',\n      \"--fgrep|--grep\",\n      \"string|regexp\",\n    );\n  }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/mochajs/mocha/blob/6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a/lib/cli/run.cjs#L60-L96","documentation":"Mocha's CLI validates run options before starting and refuses to run when more than one 'one-and-done' flag (--help, --version, --list-interfaces, --list-reporters) is supplied. These flags print info and exit immediately, so combining them is meaningless. Mocha throws createUnsupportedError naming the conflicting flags.","triggerScenarios":"Running the mocha CLI with two or more truthy one-and-done options in argv, e.g. `mocha --help --version` or `mocha --list-reporters --list-interfaces`; programmatically, calling run() with an argv object where multiple ONE_AND_DONES keys are truthy.","commonSituations":"Shell scripts or npm scripts appending flags so two info flags end up together; wrappers passing argv objects where leftover truthy values from a previous config remain; alias confusion like -V vs --version duplicates.","solutions":["Remove one of the conflicting one-and-done flags so only a single flag like --help or --version is passed","Audit the script/alias that composes the mocha command line and fix flag concatenation","If invoking programmatically, ensure the argv object sets only one of the ONE_AND_DONES keys truthy"],"exampleFix":"// before\nmocha --help --version\n// after\nmocha --help","handlingStrategy":"validation","validationCode":"const ONE_AND_DONES = ['help','h','version','V','list-interfaces','list-reporters'];\nconst active = ONE_AND_DONES.filter((o) => argv[o]);\nif (active.length > 1) throw new Error(`Pick only one of: ${active.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  mochaRun(argv);\n} catch (err) {\n  if (err.code === 'ERR_MOCHA_UNSUPPORTED') {\n    console.error(`Fix CLI flags: ${err.message}`);\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Keep at most one one-and-done flag in any composed mocha command","Build CLI invocations from a single source of truth instead of concatenating scripts","Log the final argv in CI scripts to spot duplicated flags"],"tags":["cli","argument-validation"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a","analyzedAt":"2026-09-01T03:41:47.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}