diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 59172ba7e41c5a..6c2e7b4c7ac79b 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -81,7 +81,7 @@ const maybeOverridePrepareStackTrace = (globalThis, error, trace) => { // https://crbug.com/v8/7848 // `globalThis` is the global that contains the constructor which // created `error`. - if (typeof globalThis.Error.prepareStackTrace === 'function') { + if (typeof globalThis.Error?.prepareStackTrace === 'function') { return globalThis.Error.prepareStackTrace(error, trace); } // We still have legacy usage that depends on the main context's `Error`