Skip to content

Commit 444cb06

Browse files
committed
fix: npm_execpath when running bundled pnpm CLI
1 parent ac106f9 commit 444cb06

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ function lifecycle (pkg, stage, wd, opts) {
8585
const env = makeEnv(pkg, opts)
8686
env.npm_lifecycle_event = stage
8787
env.npm_node_execpath = env.NODE = env.NODE || process.execPath
88-
env.npm_execpath = require.main ? require.main.filename : process.cwd()
88+
if (process.pkg != null) {
89+
// If the pnpm CLI was bundled by vercel/pkg then we cannot use the js path for npm_execpath
90+
// because in that case the js is in a virtual filesystem inside the executor.
91+
// Instead, we use the path to the exe file.
92+
env.npm_execpath = process.execPath
93+
} else {
94+
env.npm_execpath = require.main ? require.main.filename : process.cwd()
95+
}
8996
env.INIT_CWD = process.cwd()
9097
env.npm_config_node_gyp = env.npm_config_node_gyp || DEFAULT_NODE_GYP_PATH
9198
if (opts.extraEnv) {

0 commit comments

Comments
 (0)