mirror of https://github.com/nodejs/node.git
module: fix ERR_REQUIRE_ESM for parentPath null
PR-URL: https://github.com/nodejs/node/pull/40145 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
d9ebc04e9b
commit
481c1609d8
|
@ -1459,8 +1459,8 @@ E('ERR_REQUIRE_ESM',
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const basename = path.basename(filename) === path.basename(parentPath) ?
|
const basename = parentPath && path.basename(filename) ===
|
||||||
filename : path.basename(filename);
|
path.basename(parentPath) ? filename : path.basename(filename);
|
||||||
if (hasEsmSyntax) {
|
if (hasEsmSyntax) {
|
||||||
msg += `\nInstead change the require of ${basename} in ${parentPath} to` +
|
msg += `\nInstead change the require of ${basename} in ${parentPath} to` +
|
||||||
' a dynamic import() which is available in all CommonJS modules.';
|
' a dynamic import() which is available in all CommonJS modules.';
|
||||||
|
|
Loading…
Reference in New Issue