diff --git a/lib/internal/bootstrap/cache.js b/lib/internal/bootstrap/cache.js index 479003514cc2a1..f69f1252ad8747 100644 --- a/lib/internal/bootstrap/cache.js +++ b/lib/internal/bootstrap/cache.js @@ -33,7 +33,7 @@ const cannotUseCache = [ // Skip modules that cannot be required when they are not // built into the binary. -if (hasInspector) { +if (!hasInspector) { cannotUseCache.push( 'inspector', 'internal/util/inspector', diff --git a/lib/internal/process/coverage.js b/lib/internal/process/coverage.js index ef37deba8a5f58..95235c8ac913a7 100644 --- a/lib/internal/process/coverage.js +++ b/lib/internal/process/coverage.js @@ -51,12 +51,13 @@ function disableAllAsyncHooks() { exports.writeCoverage = writeCoverage; function setup() { - const { Connection } = internalBinding('inspector'); - if (!Connection) { + const { hasInspector } = internalBinding('config'); + if (!hasInspector) { process._rawDebug('inspector not enabled'); return; } + const { Connection } = internalBinding('inspector'); coverageConnection = new Connection((res) => { if (coverageConnection._coverageCallback) { coverageConnection._coverageCallback(res);