Skip to content

Commit 0e39af9

Browse files
committed
Use util
1 parent d7b9b66 commit 0e39af9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/internal/modules/cjs/loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,11 @@ function trySelf(parentPath, request, conditions) {
662662
function tryPackageMapResolveCJS(request, parent, conditions) {
663663
if (!hasPackageMap()) { return undefined; }
664664

665+
const parentPath = trySelfParentPath(parent);
666+
if (!parentPath) { return undefined; }
667+
665668
// If the resolution has no parent, use the current working directory. This
666669
// usually happens when running `node -e 'require("some-package")'`.
667-
const parentPath = parent?.filename ?? process.cwd() + path.sep;
668670
const mapped = packageMapResolve(request, parentPath);
669671

670672
if (mapped === undefined) {

0 commit comments

Comments
 (0)