Files
runner-images/images/win/scripts/Installers/Install-NodeLts.ps1
Dr e2027939f3 [Windows] use npm config instead of npm_config_cache (#2153)
The `npm_config_cache` env, if set, will have highest priority, and harder to change.

One way to un-set this is add a global workflow env, like:
```
env:
  npm_config_cache: ''
```

This commit change the cache config to use `npm config set cache $CachePath --global`,
which should save the path under the global npmrc at: `C:\npm\prefix\etc\npmrc`,
and allow easier later reset with user/repo level `.npmrc` files.

For the record, my usage is to unify all platform's npm cache to `~/.npm/`,
then use the same cache action config on all platform to cache the folder.
2021-01-14 19:27:02 +03:00

35 lines
1.0 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
Choco-Install -PackageName nodejs-lts -ArgumentList "--force"
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 http://registry.npmjs.org/
npm install -g cordova
npm install -g grunt-cli
npm install -g gulp-cli
npm install -g parcel-bundler
npm install -g --save-dev webpack webpack-cli
npm install -g yarn
npm install -g lerna
npm install -g node-sass
npm install -g newman
Invoke-PesterTests -TestFile "Node"