From f71100ca3dc048dc4d3ec8819e895e051500afdc Mon Sep 17 00:00:00 2001 From: Liam Jones Date: Mon, 6 Jan 2025 12:28:59 +0000 Subject: [PATCH] fix(env): improve env detection compatibility for Node The React Native test environment *is* Node but sets up a window global: https://github.com/facebook/react-native/blob/7a85b911254dbae9fac4c6d8a862a20c33e0b36a/packages/react-native/Libraries/Core/setUpGlobals.js#L18 Reintroduce the navigator.userAgent check as a fallback for detecting a Node environment --- src/core/env.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/env.ts b/src/core/env.ts index 52e3699a..ada4862b 100644 --- a/src/core/env.ts +++ b/src/core/env.ts @@ -37,7 +37,7 @@ else if (typeof document === 'undefined' && typeof self !== 'undefined') { // In worker env.worker = true; } -else if (!env.hasGlobalWindow || 'Deno' in window) { +else if (!env.hasGlobalWindow || 'Deno' in window || (navigator?.userAgent?.indexOf('Node.js') === 0)) { // In node env.node = true; env.svgSupported = true;