From edbc3cefdb0ab072fdad8d37a8ab078319384334 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Thu, 2 Nov 2023 11:34:56 +0100 Subject: [PATCH 1/2] fix(env): fix env detection compatibility for node, bun, and deno --- src/core/env.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/env.ts b/src/core/env.ts index 92c7f9e7..f1ece479 100644 --- a/src/core/env.ts +++ b/src/core/env.ts @@ -38,8 +38,11 @@ else if (typeof document === 'undefined' && typeof self !== 'undefined') { env.worker = true; } else if ( - typeof navigator === 'undefined' || - navigator.userAgent.indexOf('Node.js') === 0 + ( + typeof process !== 'undefined' + && typeof process.version === 'string' + ) + || 'Deno' in window ) { // In node env.node = true; From 1fc83cb5a8b0238c455cf15730d23cbcf13709b1 Mon Sep 17 00:00:00 2001 From: yunyin Date: Tue, 2 Apr 2024 20:58:15 +0800 Subject: [PATCH 2/2] bugfix running without navigator.userAgent --- src/core/env.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/env.ts b/src/core/env.ts index cadec668..a873873e 100644 --- a/src/core/env.ts +++ b/src/core/env.ts @@ -39,6 +39,7 @@ else if (typeof document === 'undefined' && typeof self !== 'undefined') { } else if ( typeof navigator === 'undefined' + || typeof navigator.userAgent === 'undefined' // bugfix running without navigator.userAgent || navigator.userAgent.indexOf('Node.js') === 0 ) { // In node