fix: robust node.js version parsing in installers

Improved Node.js version check logic to handle prefixed version strings and avoid brittle cut commands. Verified with multiple version formats including v24.11.1.
This commit is contained in:
Trae Agent
2026-01-29 11:26:11 +04:00
Unverified
parent 4cf8412ec9
commit 2ba9dedfb0
4 changed files with 36 additions and 12 deletions

View File

@@ -179,10 +179,18 @@ function Install-Dependencies {
# Check Node.js
$nodeCmd = Get-Command node -ErrorAction SilentlyContinue
if ($nodeCmd) {
$version = & node --version
Write-ColorOutput "Node.js found: $version" -Type Success
$nodeFullVersion = & node --version
$nodeMajorVersion = ($nodeFullVersion -replace '^v', '') -split '\.' | Select-Object -First 1
if ([int]$nodeMajorVersion -lt 18) {
Write-ColorOutput "Node.js version $nodeMajorVersion is too old! Node.js 18 or newer is required." -Type Error
exit 1
}
Write-ColorOutput "Node.js found: $nodeFullVersion" -Type Success
} else {
Write-ColorOutput "Node.js not found. Some features may not work." -Type Warning
Write-ColorOutput "Node.js not found. Node.js 18 or newer is required to install Claude Code." -Type Error
exit 1
}
# Check Git