{"record":{"id":"32b392c11b473411","repo":"denoland/deno","slug":"err-invalid-arg-value-32b392","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The argument 'colorMode' must be one of: 'auto', true, false. Received ${colorMode}","messagePattern":"The argument 'colorMode' must be one of: 'auto', true, false\\. Received (.+?)","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/console/constructor.mjs","lineNumber":165,"sourceCode":"    stdout,\n    stderr = stdout,\n    ignoreErrors = true,\n    colorMode = \"auto\",\n    inspectOptions,\n    groupIndentation,\n  } = options;\n\n  if (!stdout || typeof stdout.write !== \"function\") {\n    throw new ERR_CONSOLE_WRITABLE_STREAM(\"stdout\");\n  }\n  if (!stderr || typeof stderr.write !== \"function\") {\n    throw new ERR_CONSOLE_WRITABLE_STREAM(\"stderr\");\n  }\n\n  if (typeof colorMode !== \"boolean\" && colorMode !== \"auto\") {\n    // Match Node: reason lists the accepted values (see\n    // lib/internal/console/constructor.js).\n    throw new ERR_INVALID_ARG_VALUE(\n      \"colorMode\",\n      colorMode,\n      \"must be one of: 'auto', true, false\",\n    );\n  }\n\n  if (groupIndentation !== undefined) {\n    validateInteger(\n      groupIndentation,\n      \"groupIndentation\",\n      0,\n      kMaxGroupIndentation,\n    );\n  }\n\n  if (inspectOptions !== undefined) {\n    validateObject(inspectOptions, \"options.inspectOptions\");\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/console/constructor.mjs#L147-L183","documentation":"The Console constructor's colorMode option accepts exactly three values: true, false, or the string 'auto'. Anything else - 'always', 'yes', 1, null, 'TRUE' - throws ERR_INVALID_ARG_VALUE at construction. The check is strict about type and case, matching Node's lib/internal/console/constructor.js.","triggerScenarios":"new Console({ stdout, colorMode: 'always' }) (unrecognized string); colorMode: 1 (number, not boolean); colorMode: null; colorMode wired straight from an env var like process.env.FORCE_COLOR ('1') without normalization.","commonSituations":"Mapping CLI flags or env variables (FORCE_COLOR, NO_COLOR, TERM) to colorMode without converting; assuming chalk-style 'always' is accepted; config schemas that allow free-form strings.","solutions":["Normalize before constructing: const colorMode = forceColor ? true : 'auto'","Restrict your config schema to true | false | 'auto' and validate early","Omit colorMode entirely - the default 'auto' detects TTY correctly in most cases","Map common inputs explicitly: FORCE_COLOR=0 -> false, FORCE_COLOR=1/true -> true, unset -> 'auto'"],"exampleFix":"// before\nconst logger = new Console({ stdout, colorMode: process.env.FORCE_COLOR }); // '1' -> ERR_INVALID_ARG_VALUE\n\n// after\nconst raw = process.env.FORCE_COLOR;\nconst colorMode = raw === undefined ? 'auto' : raw !== '0';\nconst logger = new Console({ stdout, colorMode });","handlingStrategy":"validation","validationCode":"function normalizeColorMode(v) {\n  if (v === undefined) return 'auto';\n  if (v === 'auto' || typeof v === 'boolean') return v;\n  throw new TypeError(`colorMode must be 'auto', true, or false; got ${String(v)}`);\n}\nconst logger = new Console({ stdout, colorMode: normalizeColorMode(cfg.colorMode) });","typeGuard":"const isValidColorMode = (v) => v === 'auto' || v === true || v === false;","tryCatchPattern":"try {\n  logger = new Console({ stdout, colorMode: cfg.colorMode });\n} catch (e) {\n  if (e?.code === 'ERR_INVALID_ARG_VALUE') logger = new Console({ stdout });\n  else throw e;\n}","preventionTips":["Convert env vars and CLI flags to booleans before they reach Console","Restrict config schemas to the literal union true | false | 'auto'","Omit colorMode when unsure - 'auto' TTY detection is the sensible default"],"tags":["console","options","colors","argument-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}