Skip to content
Myr

[Fix] `nvm install-latest-npm`: ensure npm 10 does not install on unsupported nodes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

See https://github.com/npm/cli/pull/6674

authored by Jordan Harband · committed by Jordan Harband · parent 8fbf8ab · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • other:+21 added−0 removed

1 file+21 added−0 removed

modified:nvm.sh+21 added
315 unmodified lines
316 NVM_IS_18_OR_ABOVE=0317 if [ $NVM_IS_17_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 18.0.0; then318 NVM_IS_18_OR_ABOVE=1319 fi320 local NVM_IS_18_17_OR_ABOVE321 NVM_IS_18_17_OR_ABOVE=0322 if [ $NVM_IS_18_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 18.17.0; then323 NVM_IS_18_17_OR_ABOVE=1324 fi325 local NVM_IS_19_OR_ABOVE326 NVM_IS_19_OR_ABOVE=0327 if [ $NVM_IS_18_17_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 19.0.0; then328 NVM_IS_19_OR_ABOVE=1329 fi330 local NVM_IS_20_5_OR_ABOVE331 NVM_IS_20_5_OR_ABOVE=0332 if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then333 NVM_IS_20_5_OR_ABOVE=1334 fi335336 if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {337 [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \338 }; then
32 unmodified lines
371 || { [ $NVM_IS_17_OR_ABOVE -eq 1 ] && [ $NVM_IS_18_OR_ABOVE -eq 0 ]; } \372 ; then373 nvm_echo '* `npm` `v8.x` is the last version that works on `node` `v12`, `v14.13` - `v14.16`, or `v16.0` - `v16.12`'374 $NVM_NPM_CMD install -g npm@8375 elif \376 [ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \377 || { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \378 ; then379 nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'380 $NVM_NPM_CMD install -g npm@9381 else382 nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'383 $NVM_NPM_CMD install -g npm384 fi
4032 unmodified lines