Skip to content

Commit d6da190

Browse files
committed
fix: don't fail when require.main is undefined
1 parent 66459f9 commit d6da190

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ 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.filename
88+
env.npm_execpath = require.main ? require.main.filename : process.cwd()
8989
env.INIT_CWD = process.cwd()
9090
env.npm_config_node_gyp = env.npm_config_node_gyp || DEFAULT_NODE_GYP_PATH
9191
if (opts.extraEnv) {

0 commit comments

Comments
 (0)