Files
runner-images/images/win/scripts/Installers/Install-NodeLts.ps1
Mikhail Timofeev 0ddb8a2302 [Windows] Use Get-LatestChocoPackageVersion to get nodejs version to install (#4469)
* Use Get-LatestChocoPackageVersion to get nodejs
* Fix typo in Send-RequestToChocolateyPackages
2021-11-11 13:13:07 +03:00

33 lines
1.1 KiB
PowerShell

################################################################################
## File: Install-NodeLts.ps1
## Desc: Install nodejs-lts and other common node tools.
## Must run after python is configured
################################################################################
$PrefixPath = 'C:\npm\prefix'
$CachePath = 'C:\npm\cache'
New-Item -Path $PrefixPath -Force -ItemType Directory
New-Item -Path $CachePath -Force -ItemType Directory
$defaultVersion = (Get-ToolsetContent).node.default
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion $defaultVersion -PackageName "nodejs"
Choco-Install -PackageName nodejs -ArgumentList "--version=$versionToInstall"
Add-MachinePathItem $PrefixPath
$env:Path = Get-MachinePath
setx npm_config_prefix $PrefixPath /M
$env:npm_config_prefix = $PrefixPath
npm config set cache $CachePath --global
npm config set registry https://registry.npmjs.org/
$globalNpmPackages = (Get-ToolsetContent).npm.global_packages
$globalNpmPackages | ForEach-Object {
npm install -g $_.name
}
Invoke-PesterTests -TestFile "Node"