mirror of
https://github.com/actions/runner-images.git
synced 2025-12-13 20:56:47 +00:00
* Apply code style rules to Windows scripts * Fix typo * Fix configure-toolset script * Fix parameters in Msys2 installation script * Improve log readability * Remove broken exit code validation
33 lines
1.1 KiB
PowerShell
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
|
|
Update-Environment
|
|
|
|
[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"
|