Files
runner-images-sangeeth/images/windows/scripts/build/Install-NodeJS.ps1
Vasilii Polikarpov d3e630f774 [Windows] Implement installation helpers refactoring (#8865)
* [Windows] Refactor base Installer helper functions

* Fix helper name

* Fix name gen logic and improve error handling

* Fix hash checking logic

* Fix Install-VsixExtension invocation

* Fix variable name in Install-OpenSSL.ps1

* Fix type for git downloadUrl
2023-11-22 15:14:08 +01:00

33 lines
1.1 KiB
PowerShell

################################################################################
## File: Install-NodeJS.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 = Resolve-ChocoPackageVersion -PackageName "nodejs" -TargetVersion $defaultVersion
Install-ChocoPackage nodejs -ArgumentList "--version=$versionToInstall"
Add-MachinePathItem $PrefixPath
$env:Path = Get-MachinePath
[Environment]::SetEnvironmentVariable("npm_config_prefix", $PrefixPath, "Machine")
$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"