diff --git a/lib/bn.js b/lib/bn.js index 896efa9d..982f6383 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -370,7 +370,11 @@ // Check Symbol.for because not everywhere where Symbol defined // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { - BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } } else { BN.prototype.inspect = inspect; }