File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -65,10 +65,13 @@ func run(options *RunOptions) error {
65
65
command := options .Cmd [0 ]
66
66
67
67
oldPath := os .Getenv ("PATH" )
68
+ oldNpmConfigPrefix := os .Getenv ("NPM_CONFIG_PREFIX" )
68
69
69
70
defer os .Setenv ("PATH" , oldPath )
71
+ defer os .Setenv ("NPM_CONFIG_PREFIX" , oldNpmConfigPrefix )
70
72
71
73
os .Setenv ("PATH" , util .AppendEnvPath (binaryFileDir ))
74
+ os .Setenv ("NPM_CONFIG_PREFIX" , nodeEnvPath )
72
75
73
76
if len (options .Cmd ) == 1 {
74
77
process = exec .Command (command )
Original file line number Diff line number Diff line change @@ -73,13 +73,17 @@ func Use(constraint *string) error {
73
73
}
74
74
75
75
oldPath := os .Getenv ("PATH" )
76
- defer os .Setenv ("PATH" , oldPath ) // 确保在函数返回时恢复原始的 PATH
76
+ oldNpmConfigPrefix := os .Getenv ("NPM_CONFIG_PREFIX" )
77
+ defer os .Setenv ("PATH" , oldPath ) // 确保在函数返回时恢复原始的 PATH
78
+ defer os .Setenv ("NPM_CONFIG_PREFIX" , oldNpmConfigPrefix ) // 确保在函数返回时恢复原始的 NPM_CONFIG_PREFIX
77
79
78
80
// 设置新的 PATH 变量
79
81
os .Setenv ("PATH" , util .AppendEnvPath (binaryFileDir ))
82
+ os .Setenv ("NPM_CONFIG_PREFIX" , nodePath )
80
83
81
84
if err := crosspty .Start (shellPath , map [string ]string {
82
- "PATH" : os .Getenv ("PATH" ),
85
+ "NPM_CONFIG_PREFIX" : os .Getenv ("NPM_CONFIG_PREFIX" ),
86
+ "PATH" : os .Getenv ("PATH" ),
83
87
}, fmt .Sprintf ("Welcome to the nodapt shell, Currently using node %s!" , * version )); err != nil {
84
88
return errors .WithStack (err )
85
89
}
You can’t perform that action at this time.
0 commit comments