Skip to content

Instantly share code, notes, and snippets.

@oberonlai
Created March 26, 2026 02:25
Show Gist options
  • Select an option

  • Save oberonlai/61ef05497999adc560600fceaabfe2b8 to your computer and use it in GitHub Desktop.

Select an option

Save oberonlai/61ef05497999adc560600fceaabfe2b8 to your computer and use it in GitHub Desktop.
Windows 一鍵安裝 Claude Code(Node.js + Git + Claude Code)— 需以系統管理員身分執行 PowerShell
$ErrorActionPreference = "Stop"
Write-Host "🔍 查詢最新版本..."
# 取得最新 LTS Node 版本
$nodeList = Invoke-RestMethod "https://nodejs.org/dist/index.json"
$nodeVer = ($nodeList | Where-Object { $_.lts } | Select-Object -First 1).version.TrimStart('v')
Write-Host "📦 Node.js 最新 LTS:v$nodeVer"
# 取得最新 Git for Windows(GitHub API)
$gitRelease = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest"
$gitAsset = $gitRelease.assets | Where-Object { $_.name -match "Git-.*-64-bit\.exe" } | Select-Object -First 1
$gitUrl = $gitAsset.browser_download_url
Write-Host "📦 Git 最新版:$($gitRelease.tag_name)"
# 安裝 Node.js
$nodeMsi = "$env:TEMP\node.msi"
Write-Host "`n⬇️ 下載 Node.js..."
Invoke-WebRequest "https://nodejs.org/dist/v${nodeVer}/node-v${nodeVer}-x64.msi" -OutFile $nodeMsi
Write-Host "🔧 安裝中..."
Start-Process msiexec -Wait -ArgumentList "/i `"$nodeMsi`" /quiet /norestart"
Remove-Item $nodeMsi
# 安裝 Git
$gitExe = "$env:TEMP\git_installer.exe"
Write-Host "`n⬇️ 下載 Git..."
Invoke-WebRequest $gitUrl -OutFile $gitExe
Write-Host "🔧 安裝中..."
Start-Process $gitExe -Wait -ArgumentList "/VERYSILENT /NORESTART /NOCANCEL /SP-"
Remove-Item $gitExe
# 刷新環境變數(讓 npm 指令立即可用)
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path","User")
# 安裝 Claude Code
Write-Host "`n🤖 安裝 Claude Code..."
npm install -g @anthropic-ai/claude-code
Write-Host ""
Write-Host "✅ 全部完成!"
Write-Host " Node → $(node -v)"
Write-Host " npm → $(npm -v)"
Write-Host " Git → $(git --version)"
Write-Host " Claude → $(claude --version)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment