[Fix] `latest-npm`: ensure npm 7 is not installed on node < 10

Jordan Harband 2020-09-23 14:50:33 -07:00
parent 6110d31969
commit c7ca08d575
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 9 additions and 0 deletions

9
nvm.sh
View File

@ -243,6 +243,12 @@ nvm_install_latest_npm() {
fi
fi
local NVM_IS_10_OR_ABOVE
NVM_IS_10_OR_ABOVE=0
if [ $NVM_IS_9_3_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 10.0.0; then
NVM_IS_10_OR_ABOVE=1
fi
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \
}; then
@ -260,6 +266,9 @@ nvm_install_latest_npm() {
; then
nvm_echo '* `npm` `v6.9` is the last version that works on `node` `v6.0.x`, `v6.1.x`, `v9.0.x`, `v9.1.x`, or `v9.2.x`'
$NVM_NPM_CMD install -g npm@6.9
elif [ $NVM_IS_10_OR_ABOVE -eq 0 ]; then
nvm_echo '* `npm` `v6.x` is the last version that works on `node` below `v10.0.0`'
$NVM_NPM_CMD install -g npm@6
else
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
$NVM_NPM_CMD install -g npm