Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
esm: improve commonjs hint on module not found
Adds hint when module specifier is a file URL.

Refs: #31906
  • Loading branch information
aduh95 authored May 14, 2020
commit ed3dfc5ee925c94dd832da3aa56479528ea4db3d
3 changes: 3 additions & 0 deletions lib/internal/modules/esm/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down