diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 8bff3fc9dfd251..cbcdb020ed7cd3 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -758,6 +758,9 @@ function defaultResolve(specifier, context = {}, defaultResolveUnused) { // resolved CommonJS module if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') { + if (StringPrototypeStartsWith(specifier, 'file://')) { + specifier = fileURLToPath(specifier); + } const found = resolveAsCommonJS(specifier, parentURL); if (found) { // Modify the stack and message string to include the hint