Skip to content

Commit a94a5ba

Browse files
committed
module: fix check for package.json at volume root
1 parent 979ec42 commit a94a5ba

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎lib/internal/modules/cjs/loader.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const{
4141
SafeMap,
4242
String,
4343
StringPrototypeIndexOf,
44+
StringPrototypeLastIndexOf,
4445
StringPrototypeMatch,
4546
StringPrototypeSlice,
4647
StringPrototypeStartsWith,
@@ -286,12 +287,13 @@ function readPackageScope(checkPath){
286287
constrootSeparatorIndex=checkPath.indexOf(path.sep);
287288
letseparatorIndex;
288289
while(
289-
(separatorIndex=checkPath.lastIndexOf(path.sep))>rootSeparatorIndex
290+
(separatorIndex=StringPrototypeLastIndexOf(checkPath,path.sep))>=
291+
rootSeparatorIndex
290292
){
291293
checkPath=checkPath.slice(0,separatorIndex);
292294
if(checkPath.endsWith(path.sep+'node_modules'))
293295
returnfalse;
294-
constpjson=readPackage(checkPath);
296+
constpjson=readPackage(checkPath+path.sep);
295297
if(pjson)return{
296298
path: checkPath,
297299
data: pjson

0 commit comments

Comments
(0)