diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js index f02bb5cde70772..9ee7d473a74ef2 100644 --- a/lib/internal/modules/esm/get_format.js +++ b/lib/internal/modules/esm/get_format.js @@ -56,7 +56,7 @@ function defaultGetFormat(url, context, defaultGetFormatUnused) { } else if (parsed.protocol === 'file:') { const ext = extname(parsed.pathname); let format; - if (ext === '.js') { + if (ext === '.js' || ext === '') { format = getPackageType(parsed.href) === 'module' ? 'module' : 'commonjs'; } else { format = extensionFormatMap[ext];