From 43dcc76283516e03075a10f97eba9a6950005046 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 7 Jan 2025 19:59:36 +0100 Subject: [PATCH] chore(NODE-6636): set proper npm version on node install --- .evergreen/install-node.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.evergreen/install-node.sh b/.evergreen/install-node.sh index adafafd0..d42c3b92 100755 --- a/.evergreen/install-node.sh +++ b/.evergreen/install-node.sh @@ -6,9 +6,16 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) pushd $SCRIPT_DIR NODE_LTS_VERSION=${NODE_LTS_VERSION:-20} -# npm version can be defined in the environment for cases where we need to install -# a version lower than latest to support EOL Node versions. -NPM_VERSION=${NPM_VERSION:-latest} +# If NODE_LTS_VERSION is numeric and less than 18, default to 9, if less than 20, default to 10. +# Do not override if it is already set. +if [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 18 ]]; then + NPM_VERSION=${NPM_VERSION:-9} +elif [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 20 ]]; then + NPM_VERSION=${NPM_VERSION:-10} +else + NPM_VERSION=${NPM_VERSION:-latest} +fi +export NPM_VERSION=${NPM_VERSION} source "./init-node-and-npm-env.sh"