fix(bin): don't add non-directory to NODE_PATH in command shim (#3240)

close #3156
This commit is contained in:
Zoltan Kochan
2021-03-14 03:40:24 +02:00
committed by Zoltan Kochan
parent dd12cf6ec0
commit 6350a33811
2 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/link-bins": patch
---
Don't add a non-directory to the NODE_PATH declared in the command shim.

View File

@@ -175,11 +175,12 @@ async function linkBin (cmd: CommandInfo, binsDir: string) {
}
async function getBinNodePaths (target: string): Promise<string[]> {
const targetRealPath = await fs.realpath(target)
const targetDir = path.dirname(target)
const targetRealPath = await fs.realpath(targetDir)
return R.union(
Module['_nodeModulePaths'](targetRealPath),
Module['_nodeModulePaths'](target)
Module['_nodeModulePaths'](targetDir)
)
}