diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index 61565cc5932564..fdad580b3b6158 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -104,7 +104,7 @@ const builtinLibs = [ 'stream', 'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib' ]; -if (typeof process.binding('inspector').connect === 'function') { +if (typeof process.binding('inspector').open === 'function') { builtinLibs.push('inspector'); builtinLibs.sort(); } diff --git a/test/parallel/test-module-cjs-helpers.js b/test/parallel/test-module-cjs-helpers.js new file mode 100644 index 00000000000000..1ed9746198a606 --- /dev/null +++ b/test/parallel/test-module-cjs-helpers.js @@ -0,0 +1,11 @@ +'use strict'; +// Flags: --expose-internals + +require('../common'); +const assert = require('assert'); +const { builtinLibs } = require('internal/modules/cjs/helpers'); + +const hasInspector = process.config.variables.v8_enable_inspector === 1; + +const expectedLibs = hasInspector ? 32 : 31; +assert.strictEqual(builtinLibs.length, expectedLibs);