File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -386,13 +386,23 @@ public static void RunNpmCommand(string arguments, string workingDirectory)
386386 }
387387 else // macOS / Linux
388388 {
389- // Fallback to /bin/bash to find 'npm' in PATH
390- startInfo . FileName = "/bin/bash" ;
391- startInfo . Arguments = $ "-c \" npm { arguments } \" ";
389+ string userShell = Environment . GetEnvironmentVariable ( "SHELL" ) ?? "/bin/bash" ;
390+ string shellName = Path . GetFileName ( userShell ) ;
391+
392+ // Source rc file to init version managers (nvm, fnm, volta) - GUI apps don't inherit shell env
393+ string rcFile = shellName == "zsh" ? ".zshrc" : ".bashrc" ;
394+
395+ startInfo . FileName = userShell ;
396+ startInfo . Arguments = $ "-c \" source ~/{ rcFile } 2>/dev/null || true; npm { arguments } \" ";
392397
393- // Ensure PATH includes common npm locations and current PATH
398+ // Fallback PATH for common npm locations
394399 string currentPath = Environment . GetEnvironmentVariable ( "PATH" ) ?? string . Empty ;
395- string extraPaths = "/usr/local/bin:/opt/homebrew/bin" ;
400+ string homeDir = Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) ;
401+ string extraPaths = string . Join ( ":" ,
402+ "/usr/local/bin" ,
403+ "/opt/homebrew/bin" ,
404+ $ "{ homeDir } /.nvm/versions/node/default/bin" // nvm default alias
405+ ) ;
396406 startInfo . EnvironmentVariables [ "PATH" ] = $ "{ extraPaths } :{ currentPath } ";
397407 }
398408
You can’t perform that action at this time.
0 commit comments