{"record":{"id":"19373aa0c3297f8a","repo":"denoland/deno","slug":"err-parse-args-invalid-option-value","errorCode":"ERR_PARSE_ARGS_INVALID_OPTION_VALUE","errorMessage":"Option '${token.rawName}' argument is ambiguous.\nDid you forget to specify the option argument for '${token.rawName}'?\nTo specify an option argument starting with a dash use ${example}.","messagePattern":"Option '(.+?)' argument is ambiguous\\.\nDid you forget to specify the option argument for '(.+?)'\\?\nTo specify an option argument starting with a dash use (.+?)\\.","errorType":"exception","errorClass":"NodeTypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/util/parse_args/parse_args.js","lineNumber":89,"sourceCode":"\n  // Normally first two arguments are executable and script, then CLI arguments\n  return ArrayPrototypeSlice(proc.argv, 2);\n}\n\n/**\n * In strict mode, throw for possible usage errors like --foo --bar\n * @param {object} token - from tokens as available from parseArgs\n */\nfunction checkOptionLikeValue(token) {\n  if (!token.inlineValue && isOptionLikeValue(token.value)) {\n    // Only show short example if user used short option.\n    const example = StringPrototypeStartsWith(token.rawName, \"--\")\n      ? `'${token.rawName}=-XYZ'`\n      : `'--${token.name}=-XYZ' or '${token.rawName}-XYZ'`;\n    const errorMessage = `Option '${token.rawName}' argument is ambiguous.\nDid you forget to specify the option argument for '${token.rawName}'?\nTo specify an option argument starting with a dash use ${example}.`;\n    throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(errorMessage);\n  }\n}\n\n/**\n * In strict mode, throw for usage errors.\n * @param {object} config - from config passed to parseArgs\n * @param {object} token - from tokens as available from parseArgs\n */\nfunction checkOptionUsage(config, token) {\n  if (!ObjectHasOwn(config.options, token.name)) {\n    throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(\n      token.rawName,\n      config.allowPositionals,\n    );\n  }\n\n  const short = optionsGetOwn(config.options, token.name, \"short\");\n  const shortAndLong = `${short ? `-${short}, ` : \"\"}--${token.name}`;","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/util/parse_args/parse_args.js#L71-L107","documentation":"In strict mode (the default), util.parseArgs treats an option-like value that is not inline ('--file --bar') as a probable mistake: the developer likely forgot the argument for the previous option. It throws ERR_PARSE_ARGS_INVALID_OPTION_VALUE with a hint to use '=' inline syntax for dash-leading values.","triggerScenarios":"util.parseArgs({options: {file: {type: 'string'}}, args: ['--file', '--verbose']}); a dash-leading value like --rate -0.5 passed as a separate token; forwarding user tokens verbatim into parseArgs.","commonSituations":"CLIs that accept negative numbers or dash-prefixed patterns (--delimiter --) as option values; args built by joining arrays where the value slot received the next flag.","solutions":["Use inline assignment: --file=-verbose (or -f-verbose for short options)","Place dash-leading values after the '--' terminator or reorder args","If the form is legitimate for your tool, parse with strict: false (permissive mode)"],"exampleFix":"// before\nparseArgs({ options: { file: { type: 'string' } }, args: ['--file', '--sort'] }); // throws\n\n// after\nparseArgs({ options: { file: { type: 'string' } }, args: ['--file=--sort'] }); // ok","handlingStrategy":"try-catch","validationCode":"const looksOption = (v) => typeof v === 'string' && v.startsWith('-') && v !== '-';\n// build args with inline values when a value may start with '-':\nconst args = [`--file=${userValue}`]; // not '--file', userValue","typeGuard":null,"tryCatchPattern":"try {\n  const { values } = parseArgs({ options, args });\n} catch (err) {\n  if (err.code === 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE') {\n    console.error(`Usage error: ${err.message}`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Emit dash-leading values inline with '=' when generating args","Validate user input before forwarding to parseArgs","Document the '=' form for values that start with a dash"],"tags":["parse-args","cli","node-compat","argument-validation"],"backgroundTag":"cli-option-parsing","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}