Skip to content

Commit

Permalink
[Fix] install-latest-npm: npm v6.10 breaks on node v6.0, `v…
Browse files Browse the repository at this point in the history
…6.1`, and `v9.0`-`v9.2`
  • Loading branch information
ljharb committed Nov 3, 2019
1 parent 1eca354 commit 100861d
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,29 @@ nvm_install_latest_npm() {

local NVM_IS_6_OR_ABOVE
NVM_IS_6_OR_ABOVE=0
local NVM_IS_6_2_OR_ABOVE
NVM_IS_6_2_OR_ABOVE=0
if [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 6.0.0; then
NVM_IS_6_OR_ABOVE=1
if nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 6.2.0; then
NVM_IS_6_2_OR_ABOVE=1
fi
fi

local NVM_IS_9_OR_ABOVE
NVM_IS_9_OR_ABOVE=0
local NVM_IS_9_3_OR_ABOVE
NVM_IS_9_3_OR_ABOVE=0
if [ $NVM_IS_6_2_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 9.0.0; then
NVM_IS_9_OR_ABOVE=1
if nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 9.3.0; then
NVM_IS_9_3_OR_ABOVE=1
fi
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
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
nvm_echo '* `npm` `v5.3.x` is the last version that works on `node` 4.x versions below v4.4, or 5.x versions below v5.10, due to `Buffer.alloc`'
$NVM_NPM_CMD install -g npm@5.3
elif [ $NVM_IS_4_4_OR_BELOW -eq 0 ] && nvm_version_greater 4.7.0 "${NODE_VERSION}"; then
Expand All @@ -238,6 +254,12 @@ nvm_install_latest_npm() {
elif [ $NVM_IS_6_OR_ABOVE -eq 0 ]; then
nvm_echo '* `npm` `v5.x` is the last version that works on `node` below `v6.0.0`'
$NVM_NPM_CMD install -g npm@5
elif \
{ [ $NVM_IS_6_OR_ABOVE -eq 1 ] && [ $NVM_IS_6_2_OR_ABOVE -eq 0 ]; } \
|| { [ $NVM_IS_9_OR_ABOVE -eq 1 ] && [ $NVM_IS_9_3_OR_ABOVE -eq 0 ]; } \
; 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
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
Expand Down

0 comments on commit 100861d

Please sign in to comment.