diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index 206db0b3c67178..78556f6a5afc8f 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -14,6 +14,7 @@ const { ReflectSet, SafeSet, StringPrototypeSlice, + StringPrototypeStartsWith, StringPrototypeToUpperCase, globalThis, } = primordials; @@ -147,11 +148,13 @@ class Hooks { */ async register(urlOrSpecifier, parentURL, data) { const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader(); - const keyedExports = await cascadedLoader.import( - urlOrSpecifier, - parentURL, - kEmptyObject, - ); + const keyedExports = StringPrototypeStartsWith(urlOrSpecifier, 'node:internal/') ? + require(StringPrototypeSlice(urlOrSpecifier, 5)) : + await cascadedLoader.import( + urlOrSpecifier, + parentURL, + kEmptyObject, + ); await this.addCustomLoader(urlOrSpecifier, keyedExports, data); }