Skip to content

Commit 35d0592

Browse files
authored
chore(NODE-6636): set proper npm version on node install (#573)
1 parent e722507 commit 35d0592

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.evergreen/install-node.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
66
pushd $SCRIPT_DIR
77

88
NODE_LTS_VERSION=${NODE_LTS_VERSION:-20}
9-
# npm version can be defined in the environment for cases where we need to install
10-
# a version lower than latest to support EOL Node versions.
11-
NPM_VERSION=${NPM_VERSION:-latest}
9+
# If NODE_LTS_VERSION is numeric and less than 18, default to 9, if less than 20, default to 10.
10+
# Do not override if it is already set.
11+
if [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 18 ]]; then
12+
NPM_VERSION=${NPM_VERSION:-9}
13+
elif [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 20 ]]; then
14+
NPM_VERSION=${NPM_VERSION:-10}
15+
else
16+
NPM_VERSION=${NPM_VERSION:-latest}
17+
fi
18+
export NPM_VERSION=${NPM_VERSION}
1219

1320
source "./init-node-and-npm-env.sh"
1421

0 commit comments

Comments
 (0)