denoland/deno · error · TypeError
ERR_INCOMPATIBLE_OPTION_PAIR
ERR_INCOMPATIBLE_OPTION_PAIR
Error message
Option "options.inspectOptions.color" cannot be used in combination with option "colorMode"
What it means
Console rejects constructing with both colorMode and inspectOptions.colors set - they control the same color setting, so ERR_INCOMPATIBLE_OPTION_PAIR is thrown. The check fires whenever colorMode is present (even 'auto') together with inspectOptions.colors !== undefined. Note a grepping gotcha: the code checks the property 'colors' but the message says 'options.inspectOptions.color' (singular), matching Node's message verbatim.
Source
Thrown at ext/node/polyfills/internal/console/constructor.mjs:188
}
if (groupIndentation !== undefined) {
validateInteger(
groupIndentation,
"groupIndentation",
0,
kMaxGroupIndentation,
);
}
if (inspectOptions !== undefined) {
validateObject(inspectOptions, "options.inspectOptions");
if (
inspectOptions.colors !== undefined &&
options.colorMode !== undefined
) {
throw new ERR_INCOMPATIBLE_OPTION_PAIR(
"options.inspectOptions.color",
"colorMode",
);
}
WeakMapPrototypeSet(optionsMap, this, inspectOptions);
}
// Bind the prototype functions to this Console instance
ArrayPrototypeForEach(ObjectKeys(Console.prototype), (key) => {
// We have to bind the methods grabbed from the instance instead of from
// the prototype so that users extending the Console can override them
// from the prototype chain of the subclass.
this[key] = FunctionPrototypeBind(this[key], this);
ObjectDefineProperty(this[key], "name", {
__proto__: null,
value: key,
});
});View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Pick one knob: drop colorMode and keep inspectOptions.colors (or vice versa)
- Strip one side when merging configs: if (merged.inspectOptions?.colors !== undefined) delete merged.colorMode
- Build options conditionally: only set colorMode when inspectOptions is absent
- Document the chosen knob in your logging config schema so both never appear
Example fix
// before
new Console({ stdout, colorMode: 'auto', inspectOptions: { colors: true } }); // ERR_INCOMPATIBLE_OPTION_PAIR
// after
new Console({ stdout, colorMode: 'auto' });
// or equivalently:
new Console({ stdout, inspectOptions: { colors: true } }); Defensive patterns
Strategy: validation
Validate before calling
function buildConsoleOptions(cfg) {
if (cfg.inspectOptions?.colors !== undefined) {
const { colorMode: _drop, ...rest } = cfg;
return rest; // colors win, colorMode removed
}
return cfg;
}
const logger = new Console(buildConsoleOptions(cfg)); Try / catch
try {
logger = new Console(cfg);
} catch (e) {
if (e?.code === 'ERR_INCOMPATIBLE_OPTION_PAIR') { delete cfg.colorMode; logger = new Console(cfg); }
else throw e;
} Prevention
- Choose one color knob for the whole codebase and document it
- After deep-merging option presets, strip known-conflicting pairs before construction
- Note the error text says 'inspectOptions.color' while the property is 'colors' - search for both when grepping logs
When it happens
Trigger: new Console({ stdout, colorMode: 'auto', inspectOptions: { colors: true } }); merging a preset that sets inspectOptions.colors with user config that sets colorMode; porting code that used util.inspect colors and later added colorMode.
Common situations: Deep-merging default options with user options where each side sets a different knob; copy-pasted logger presets; incremental refactors that added colorMode without removing colors from inspectOptions.
Related errors
- ERR_INVALID_ARG_VALUE
- The url passed into 'proxy.url' has an invalid scheme for th
- Cannot construct UnsafeCallback: cannot be nonblocking
- 'options' requires at least one option to be true
- 'truncate' option requires 'write' to be true
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/fbac703645a6fba2.
Report an issue: GitHub.