From b59d6e9763272270cb6855a97ec13a2c9bbb2fbc Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Fri, 3 Jul 2020 10:21:17 +0200 Subject: [PATCH] fix: fix isNode variable not properly detecting Node.js environment This patch fixes Node.js being detected by the lack of `global.document` which isn't necessairly always true in Node (example: using JSDOM library). Instead, we're now detecting `process.versions.node` being present, which I copied over from [here](https://github.com/MatthewSH/is-node/commit/426943ae936536f9c2fd10fd58a9a46b59470097#diff-168726dbe96b3ce427e7fedce31bb0bc). Fixes #6147 --- src/environment.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/environment.ts b/src/environment.ts index 0d2a7a1f125cb..25c59864eb498 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -14,4 +14,8 @@ * limitations under the License. */ -export const isNode = typeof document === 'undefined'; +export const isNode = !!( + typeof process !== 'undefined' && + process.versions && + process.versions.node +);