diff --git a/lib/module.js b/lib/module.js index 4c567ec2b97412..921a57a8142d2c 100644 --- a/lib/module.js +++ b/lib/module.js @@ -436,7 +436,7 @@ Module._load = function(request, parent, isMain) { ESMLoader.hook(hooks); } } - await ESMLoader.import(getURLFromFilePath(request).href); + await ESMLoader.import(getURLFromFilePath(request).pathname); })() .catch((e) => { console.error(e); diff --git a/test/parallel/test-module-main-extension-lookup.js b/test/parallel/test-module-main-extension-lookup.js new file mode 100644 index 00000000000000..0a8cc47c77b2ed --- /dev/null +++ b/test/parallel/test-module-main-extension-lookup.js @@ -0,0 +1,7 @@ +'use strict'; +require('../common'); +const { execFileSync } = require('child_process'); + +const node = process.argv[0]; + +execFileSync(node, ['--experimental-modules', 'test/es-module/test-esm-ok']);