From 60e443b7d61abf538136a2e7521bed0c58a251db Mon Sep 17 00:00:00 2001 From: Aylan Brown Date: Wed, 4 Sep 2019 11:40:09 +0800 Subject: [PATCH] Browser throw `process.env is undefined` --- src/browser.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/browser.js b/src/browser.js index 987d4850..f1c85d11 100644 --- a/src/browser.js +++ b/src/browser.js @@ -214,9 +214,14 @@ function load() { // If debug isn't set in LS, and we're in Electron, try to load $DEBUG // process.env is undefined in sometimes, and it will throw a exception - if (!r && typeof process !== 'undefined' && process.env) { - r = process.env.DEBUG; + try { + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + } catch(error) { + // Browser throw `process.env is undefined` } + return r; }