[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.
This commit is contained in:
Dr
2021-01-15 00:27:02 +08:00
committed by GitHub
parent ffc82ae582
commit e2027939f3

View File

@@ -18,9 +18,7 @@ $env:Path = Get-MachinePath
setx npm_config_prefix $PrefixPath /M setx npm_config_prefix $PrefixPath /M
$env:npm_config_prefix = $PrefixPath $env:npm_config_prefix = $PrefixPath
setx npm_config_cache $CachePath /M npm config set cache $CachePath --global
$env:npm_config_cache = $CachePath
npm config set registry http://registry.npmjs.org/ npm config set registry http://registry.npmjs.org/
npm install -g cordova npm install -g cordova