39246-vm/install_node.ps1
abbashkyt-creator 7d8ce0e322 V0.1
2026-03-14 04:02:22 +03:00

26 lines
1.0 KiB
PowerShell

$url = 'https://nodejs.org/dist/v22.14.0/node-v22.14.0-win-x64.zip'
$extractTo = "$env:LOCALAPPDATA\nodejs-portable"
$zipPath = "$extractTo\node.zip"
if (!(Test-Path $extractTo)) { New-Item -ItemType Directory -Path $extractTo | Out-Null }
Write-Host "Downloading Node.js v22 LTS portable..."
Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing
Write-Host "Download complete ($([int]((Get-Item $zipPath).Length / 1MB)) MB). Extracting..."
Expand-Archive -Path $zipPath -DestinationPath $extractTo -Force
Write-Host "Extraction complete."
$nodePath = "$extractTo\node-v22.14.0-win-x64"
Write-Host "Node.js path: $nodePath"
& "$nodePath\node.exe" --version
& "$nodePath\npm.cmd" --version
# Add to current user PATH persistently
$userPath = [System.Environment]::GetEnvironmentVariable('PATH', 'User')
if ($userPath -notlike "*nodejs-portable*") {
[System.Environment]::SetEnvironmentVariable('PATH', "$nodePath;$userPath", 'User')
Write-Host "Added $nodePath to user PATH"
}
Write-Host "INSTALL_COMPLETE"