診斷結果會顯示在這裡。貼上報錯後點「開始診斷」,或點左邊的範例試試。
推薦的安裝命令
按你的終端選一條:提示符號帶 PS 的是 PowerShell,不帶的是 CMD。裝完後新開一個終端窗口,運行 claude --version 能列印版本號才算成功。
irm https://claude.ai/install.ps1 | iex
如果你用 npm 安裝:需要 Node.js 22 或更高版本。不要用 sudo,否則後續自動更新會有權限問題;升級時重新執行同一指令,不要用 npm update -g。
npm install -g @anthropic-ai/claude-code@latest
全部常見報錯速查
不確定怎麼貼上也沒關係,以你看到的報錯對號入座即可。
1'irm' is not recognized / The token '&&' is not a valid statement separator
命令和終端對不上:在 CMD 裡跑了 PowerShell 的命令,會報 irm 不識別;在 PowerShell 裡跑了 CMD 的命令,會報 && 不是有效的分隔符號;在 PowerShell 裡直接跑 macOS 的 curl -fsSL ...| bash,會報找不到參數 fsSL(PowerShell 裡的 curl 其實是 Invoke-WebRequest 的別名)。
看終端提示符:帶 PS 的是 PowerShell,用第一條;不帶 PS 的是 CMD,用第二條。
irm https://claude.ai/install.ps1 | iex
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
2'claude' is not recognized as an internal or external command
安裝位置(%USERPROFILE%\.local\bin)還沒加進 PATH,或裝完沒有新開終端。
先確認文件在不在;返回 True 的話,把它加進用戶 PATH,然後重啟終端,再運行 claude --version。如果你是在編輯器自帶的終端機裡運行的,要整個退出編輯器再打開,因為它的 PATH 來自編輯器。
Test-Path "$env:USERPROFILE\.local\bin\claude.exe"
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')claude --version
3syntax error near unexpected token '<' / < was unexpected at this time / System.Xml.XmlDocument / 403
下載到的不是安裝腳本,而是一個網頁或一個錯誤狀態。常見原因:公司代理或防火牆攔截了下載;暫時故障或網路波動;官方判定所在地區不可用(輸出裡會出現 App unavailable in region)。
先檢查網路和代理能否正常存取 claude.ai,等幾分鐘後重試原命令。注意 winget 和 Homebrew 存取的是同一批伺服器,換安裝方式解決不了網路或地區問題。
4App unavailable in region
官方判定你目前網路所在的地區不可用。這是服務端的限制,換安裝方式也解決不了。
Claude Code 僅在 Anthropic 支援的國家和地區可用,名單以官方頁面為準。可以先偵測一下目前網路的出口所在地是否在支援清單裡。
5Could not create SSL/TLS secure channel / CRYPT_E_NO_REVOCATION_CHECK
TLS 握手失敗,常見於舊版 Windows PowerShell 5.1,或公司網路做了證書檢查。
在 PowerShell 5.1 裡先啟用 TLS 1.2,並在同一個視窗再執行安裝指令。如果是公司代理在做憑證檢查,需要讓 IT 把代理的根憑證加進 Windows 憑證庫;遇到 CRYPT_E_NO_REVOCATION_CHECK 這類吊銷檢查被攔的錯誤,可以改用 winget 安裝。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
irm https://claude.ai/install.ps1 | iex
6running scripts is disabled on this system
這是用 npm 安裝時才會遇到的:PowerShell 的執行策略攔住了 npm 產生的 .ps1 啟動腳本。
選擇性一個:放寬目前使用者的執行策略(下面的指令);或改用 npm.cmd / claude.cmd;或乾脆改用原生安裝,它不受這個策略影響。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
7The process cannot access the file ... because it is being used by another process
上一次安裝還在運行,或是防毒軟體正在掃描沒下完的文件,文件被佔用。
關掉其他正在安裝的 PowerShell 窗口,等防毒軟體掃描結束,清理下載目錄後重試。
Remove-Item -Recurse -Force "$env:USERPROFILE\.claude\downloads"
irm https://claude.ai/install.ps1 | iex
8Claude Code on Windows requires Git for Windows (or PowerShell)
Claude Code 需要一個能用的 shell:裝了 Git Bash 就用 Bash,沒有就用 PowerShell,兩個都找不到才會報錯。
從 git-scm.com 安裝 Git for Windows,安裝時勾選 Add to PATH,然後重新啟動終端。如果已經裝了但仍找不到,可以在 settings.json 裡指定路徑(必須指向名為 bash.exe 或 sh.exe 的文件,指向 git-bash.exe 會被忽略)。
{
"env": {
"CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
}
}9claude opens the Claude desktop app instead of the command line
舊版 Claude Desktop 會在 WindowsApps 目錄裡註冊一個 Claude.exe,它在 PATH 裡的優先權比命令列更高,所以輸入 claude 打開的是桌面應用。
把 Claude Desktop 更新到最新版。
依據 Anthropic 官方安裝文件整理,核對日期 2026-11-18。官方命令和行為可能會變化,以官方文件為準。 查看官方安裝文檔