diff --git a/src/pretty-dom.js b/src/pretty-dom.js index f4382bcd..14c5f772 100644 --- a/src/pretty-dom.js +++ b/src/pretty-dom.js @@ -7,7 +7,7 @@ import {getConfig} from './config' const shouldHighlight = () => { // Try to safely parse env COLORS: We will default behavior if any step fails. try { - const colors = process?.env?.COLORS + const colors = typeof process !== 'undefined' ? process?.env?.COLORS : undefined if (colors) { const b = JSON.parse(colors) if (typeof b === 'boolean') return b @@ -18,7 +18,7 @@ const shouldHighlight = () => { // In all other cases, whether COLORS was a weird type, or the attempt threw: // Fall back to colorizing if we are running in node. - return !!process?.versions?.node + return typeof process !== 'undefined' && !!process.versions?.node } const {DOMCollection} = prettyFormat.plugins