Skip to content
Myr

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

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

authored by Jordan Harband · committed by Jordan Harband · parent 2bda9fd · Browse files · 3 files+44 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

3 files+44 added−0 removed

  • tests:+7 added−0 removed
  • other:+37 added−0 removed

3 files+44 added−0 removed

modified:.github/workflows/latest-npm.yml+5 added
modified:test/installation_node/install latest npm+7 added
7 unmodified lines
8\. ../../nvm.sh9set -e1011nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 1'12nvm install 12.12 >/dev/null 2>&1 || die 'install v12.12 failed'13nvm install-latest-npm || die 'nvm install-latest-npm failed: 1'14NPM_VERSION="$(npm --version)"15nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 7.0.0 \16&& nvm_version_greater 8.0.0 "${NPM_VERSION}" || die "node v12.12 updates to ${NPM_VERSION}; expected v7"1718nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 1'19nvm install 4 >/dev/null 2>&1 || die 'install v4 failed'20nvm install-latest-npm || die 'nvm install-latest-npm failed: 1'21NPM_VERSION="$(npm --version)"22nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 5.0.0 || die "node v4.x updates to ${NPM_VERSION}; expected >= v5"
29 unmodified lines
modified:nvm.sh+32 added
266 unmodified lines
267 NVM_IS_10_OR_ABOVE=0268 if [ $NVM_IS_9_3_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 10.0.0; then269 NVM_IS_10_OR_ABOVE=1270 fi271 local NVM_IS_12_LTS_OR_ABOVE272 NVM_IS_12_LTS_OR_ABOVE=0273 if [ $NVM_IS_10_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 12.13.0; then274 NVM_IS_12_LTS_OR_ABOVE=1275 fi276 local NVM_IS_13_OR_ABOVE277 NVM_IS_13_OR_ABOVE=0278 if [ $NVM_IS_12_LTS_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 13.0.0; then279 NVM_IS_13_OR_ABOVE=1280 fi281 local NVM_IS_14_LTS_OR_ABOVE282 NVM_IS_14_LTS_OR_ABOVE=0283 if [ $NVM_IS_13_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 14.15.0; then284 NVM_IS_14_LTS_OR_ABOVE=1285 fi286 local NVM_IS_15_OR_ABOVE287 NVM_IS_15_OR_ABOVE=0288 if [ $NVM_IS_14_LTS_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 15.0.0; then289 NVM_IS_15_OR_ABOVE=1290 fi291 local NVM_IS_16_OR_ABOVE292 NVM_IS_16_OR_ABOVE=0293 if [ $NVM_IS_15_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 16.0.0; then294 NVM_IS_16_OR_ABOVE=1295 fi296297 if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {298 [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \299 }; then
13 unmodified lines
313 $NVM_NPM_CMD install -g npm@6.9314 elif [ $NVM_IS_10_OR_ABOVE -eq 0 ]; then315 nvm_echo '* `npm` `v6.x` is the last version that works on `node` below `v10.0.0`'316 $NVM_NPM_CMD install -g npm@6317 elif \318 [ $NVM_IS_12_LTS_OR_ABOVE -eq 0 ] \319 || { [ $NVM_IS_13_OR_ABOVE -eq 1 ] && [ $NVM_IS_14_LTS_OR_ABOVE -eq 0 ]; } \320 || { [ $NVM_IS_15_OR_ABOVE -eq 1 ] && [ $NVM_IS_16_OR_ABOVE -eq 0 ]; } \321 ; then322 nvm_echo '* `npm` `v7.x` is the last version that works on `node` `v13`, `v15`, below `v12.13`, or `v14.0` - `v14.15`'323 $NVM_NPM_CMD install -g npm@7324 else325 nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'326 $NVM_NPM_CMD install -g npm327 fi
3962 unmodified lines