diff --git a/ClaudeCode/setup-claude-code.ps1 b/ClaudeCode/setup-claude-code.ps1 index 3c35c97..f115c98 100644 --- a/ClaudeCode/setup-claude-code.ps1 +++ b/ClaudeCode/setup-claude-code.ps1 @@ -241,6 +241,19 @@ function Install-Tool { return $false } + # 如果命令不在 PATH 中,尝试查找 npm 全局 bin 目录 + if (-not (Test-Command $ToolCommand)) { + Write-Info "正在搜索 npm 全局安装位置..." + $npmPrefix = & npm config get prefix 2>$null + if ($npmPrefix -and (Test-Path $npmPrefix)) { + $env:Path = "$npmPrefix;$env:Path" + } + $appDataNpm = "$env:APPDATA\npm" + if ((Test-Path $appDataNpm) -and ($env:Path -notlike "*$appDataNpm*")) { + $env:Path = "$appDataNpm;$env:Path" + } + } + if (Test-Command $ToolCommand) { Write-Success "$ToolName 安装成功!" return $true diff --git a/GeminiCLI/setup-gemini.ps1 b/GeminiCLI/setup-gemini.ps1 index 4e2b6fe..9e85e22 100644 --- a/GeminiCLI/setup-gemini.ps1 +++ b/GeminiCLI/setup-gemini.ps1 @@ -239,6 +239,19 @@ function Install-Tool { return $false } + # 如果命令不在 PATH 中,尝试查找 npm 全局 bin 目录 + if (-not (Test-Command $ToolCommand)) { + Write-Info "正在搜索 npm 全局安装位置..." + $npmPrefix = & npm config get prefix 2>$null + if ($npmPrefix -and (Test-Path $npmPrefix)) { + $env:Path = "$npmPrefix;$env:Path" + } + $appDataNpm = "$env:APPDATA\npm" + if ((Test-Path $appDataNpm) -and ($env:Path -notlike "*$appDataNpm*")) { + $env:Path = "$appDataNpm;$env:Path" + } + } + if (Test-Command $ToolCommand) { Write-Success "$ToolName 安装成功!" return $true diff --git a/codex/setup-codex.ps1 b/codex/setup-codex.ps1 index fec769c..59baa1e 100644 --- a/codex/setup-codex.ps1 +++ b/codex/setup-codex.ps1 @@ -241,6 +241,19 @@ function Install-Tool { return $false } + # 如果命令不在 PATH 中,尝试查找 npm 全局 bin 目录 + if (-not (Test-Command $ToolCommand)) { + Write-Info "正在搜索 npm 全局安装位置..." + $npmPrefix = & npm config get prefix 2>$null + if ($npmPrefix -and (Test-Path $npmPrefix)) { + $env:Path = "$npmPrefix;$env:Path" + } + $appDataNpm = "$env:APPDATA\npm" + if ((Test-Path $appDataNpm) -and ($env:Path -notlike "*$appDataNpm*")) { + $env:Path = "$appDataNpm;$env:Path" + } + } + if (Test-Command $ToolCommand) { Write-Success "$ToolName 安装成功!" return $true diff --git a/setup-claude-code.ps1 b/setup-claude-code.ps1 index 0fffdff..b5a54e2 100644 --- a/setup-claude-code.ps1 +++ b/setup-claude-code.ps1 @@ -240,6 +240,19 @@ function Install-Tool { return $false } + # 如果命令不在 PATH 中,尝试查找 npm 全局 bin 目录 + if (-not (Test-Command $ToolCommand)) { + Write-Info "正在搜索 npm 全局安装位置..." + $npmPrefix = & npm config get prefix 2>$null + if ($npmPrefix -and (Test-Path $npmPrefix)) { + $env:Path = "$npmPrefix;$env:Path" + } + $appDataNpm = "$env:APPDATA\npm" + if ((Test-Path $appDataNpm) -and ($env:Path -notlike "*$appDataNpm*")) { + $env:Path = "$appDataNpm;$env:Path" + } + } + if (Test-Command $ToolCommand) { Write-Success "$ToolName 安装成功!" return $true diff --git a/setup.ps1 b/setup.ps1 index 813002e..31f3ef2 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -264,6 +264,20 @@ function Install-Tool { return $false } + # 如果命令不在 PATH 中,尝试查找 npm 全局 bin 目录 + if (-not (Test-Command $Tool.Command)) { + Write-Info "正在搜索 npm 全局安装位置..." + $npmPrefix = & npm config get prefix 2>$null + if ($npmPrefix -and (Test-Path $npmPrefix)) { + $env:Path = "$npmPrefix;$env:Path" + } + # 也检查常见的 npm 全局路径 + $appDataNpm = "$env:APPDATA\npm" + if ((Test-Path $appDataNpm) -and ($env:Path -notlike "*$appDataNpm*")) { + $env:Path = "$appDataNpm;$env:Path" + } + } + if (Test-Command $Tool.Command) { Write-Success "$($Tool.Name) 安装成功!" return $true