36 lines
1.3 KiB
PowerShell
36 lines
1.3 KiB
PowerShell
# Install Node.js automatically (Run as Administrator)
|
|
|
|
Write-Host "Installing Node.js LTS..." -ForegroundColor Green
|
|
|
|
# Check if winget is available
|
|
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
|
Write-Host "Found winget, installing Node.js..." -ForegroundColor Cyan
|
|
winget install OpenJS.NodeJS
|
|
}
|
|
else {
|
|
Write-Host "winget not found. Downloading Node.js installer..." -ForegroundColor Yellow
|
|
|
|
# Download Node.js LTS
|
|
$NodeURL = "https://nodejs.org/dist/v18.16.0/node-v18.16.0-x64.msi"
|
|
$InstallerPath = "$env:TEMP\nodejs-installer.msi"
|
|
|
|
Write-Host "Downloading from: $NodeURL"
|
|
Invoke-WebRequest -Uri $NodeURL -OutFile $InstallerPath -UseBasicParsing
|
|
|
|
Write-Host "Running installer..." -ForegroundColor Cyan
|
|
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i $InstallerPath /quiet /norestart" -Wait
|
|
|
|
Remove-Item $InstallerPath
|
|
}
|
|
|
|
Write-Host "Installation complete! Refreshing environment..." -ForegroundColor Green
|
|
|
|
# Refresh PATH
|
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
|
|
|
Write-Host "Checking installation..." -ForegroundColor Cyan
|
|
node --version
|
|
npm --version
|
|
|
|
Write-Host "Ready to run npm install!" -ForegroundColor Green
|