Skip to content

Commit 972d921

Browse files
guybedfordtargos
authored andcommitted
module: fix ERR_REQUIRE_ESM for parentPath null
PR-URL: #40145 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent bbf1ed7 commit 972d921

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/internal/errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ E('ERR_REQUIRE_ESM',
14591459
return msg;
14601460
}
14611461
const path = require('path');
1462-
const basename = path.basename(filename) === path.basename(parentPath) ?
1463-
filename : path.basename(filename);
1462+
const basename = parentPath && path.basename(filename) ===
1463+
path.basename(parentPath) ? filename : path.basename(filename);
14641464
if (hasEsmSyntax) {
14651465
msg += `\nInstead change the require of ${basename} in ${parentPath} to` +
14661466
' a dynamic import() which is available in all CommonJS modules.';

0 commit comments

Comments
 (0)