From b9b0ea802068630b30e94414a85d9a7b2a76fe68 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Dec 2024 10:03:18 -0800 Subject: [PATCH] [Fix] `install-latest-npm`: npm v11 is out --- .github/workflows/latest-npm.yml | 5 +++++ nvm.sh | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/latest-npm.yml b/.github/workflows/latest-npm.yml index b368080..2f25052 100644 --- a/.github/workflows/latest-npm.yml +++ b/.github/workflows/latest-npm.yml @@ -37,6 +37,11 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} include: + - node-version: "21" + - node-version: "20.5" + - node-version: "20.4" + - node-version: "14.17" + - node-version: "14.16" - node-version: "9.2" - node-version: "9.1" - node-version: "9.0" diff --git a/nvm.sh b/nvm.sh index ed0e0b3..b23723c 100755 --- a/nvm.sh +++ b/nvm.sh @@ -354,6 +354,21 @@ nvm_install_latest_npm() { if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then NVM_IS_20_5_OR_ABOVE=1 fi + local NVM_IS_20_17_or_ABOVE + NVM_IS_20_17_or_ABOVE=0 + if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then + NVM_IS_20_17_or_ABOVE=1 + fi + local NVM_IS_21_OR_ABOVE + NVM_IS_21_OR_ABOVE=0 + if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then + NVM_IS_21_OR_ABOVE=1 + fi + local NVM_IS_22_9_OR_ABOVE + NVM_IS_22_9_OR_ABOVE=0 + if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then + NVM_IS_22_9_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}"; \ @@ -399,8 +414,15 @@ nvm_install_latest_npm() { [ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \ || { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \ ; then + # TODO: 10.8.3 can run on 16.20.2?? https://github.com/nodejs/Release/issues/884#issuecomment-2558077691 nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`' $NVM_NPM_CMD install -g npm@9 + elif \ + [ $NVM_IS_20_17_or_ABOVE -eq 0 ] \ + || { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \ + ; then + nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`' + $NVM_NPM_CMD install -g npm@10 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