Skip to content

Commit 35bb2a2

Browse files
authored
chore: update nvm environment setup (#487)
1 parent 79cb5d3 commit 35bb2a2

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

.evergreen/install-dependencies.sh

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,34 @@ if [ -z "$NODE_VERSION" ]; then
44
exit 1
55
fi
66

7+
set -o xtrace # Write all commands first to stderr
8+
set -o errexit # Exit the script with error if any of the commands fail
9+
710
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
811
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
912
NPM_TMP_DIR="${NODE_ARTIFACTS_PATH}/tmp"
10-
11-
NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip"
12-
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh"
13+
BIN_DIR="$(pwd)/bin"
14+
NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-noinstall.zip"
15+
NVM_URL="https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh"
1316

1417
# this needs to be explicitly exported for the nvm install below
1518
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
16-
export XDG_CONFIG_HOME=${NODE_ARTIFACTS_PATH}
1719

1820
# create node artifacts path if needed
19-
mkdir -p ${NVM_DIR}
20-
mkdir -p ${NPM_CACHE_DIR}
21+
mkdir -p "${NODE_ARTIFACTS_PATH}"
22+
mkdir -p "${NPM_CACHE_DIR}"
2123
mkdir -p "${NPM_TMP_DIR}"
24+
mkdir -p "${BIN_DIR}"
25+
mkdir -p "${NVM_DIR}"
26+
27+
# Add mongodb toolchain to path
28+
export PATH="${BIN_DIR}:${PATH}"
2229

2330
# install Node.js
24-
echo "--- Installing Node ${NODE_VERSION} --- "
31+
echo "Installing Node ${NODE_LTS_NAME}"
2532
if [ "$OS" == "Windows_NT" ]; then
33+
set +o xtrace
34+
2635
export NVM_HOME=`cygpath -w "$NVM_DIR"`
2736
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
2837
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH
@@ -40,17 +49,33 @@ root: $NVM_HOME
4049
path: $NVM_SYMLINK
4150
EOT
4251

43-
nvm install ${NODE_VERSION}
44-
nvm install 10.22.0 # install lts for compilation only
45-
nvm on
52+
echo "Running: nvm install lts"
53+
nvm install lts
54+
echo "Running: nvm install ${NODE_VERSION}"
55+
nvm install "${NODE_VERSION}"
56+
echo "Running: nvm use lts"
57+
nvm use lts
58+
echo "Running: npm install -g [email protected]"
59+
npm install -g [email protected] # https://github.com/npm/cli/issues/4341
60+
set -o xtrace
4661
else
62+
set +o xtrace
63+
64+
echo " Downloading nvm"
4765
curl -o- $NVM_URL | bash
4866
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
4967

50-
nvm install --no-progress ${NODE_VERSION}
51-
nvm install --no-progress 10.22.0 # install lts for compilation only
68+
echo "Running: nvm install --lts --latest-npm"
69+
nvm install --lts --latest-npm
70+
echo "Running: nvm install ${NODE_VERSION}"
71+
nvm install "${NODE_VERSION}"
72+
echo "Running: nvm use --lts"
73+
nvm use --lts
74+
75+
set -o xtrace
5276
fi
53-
nvm use 10.22.0 # use lts for setup, runtime node can be different
77+
78+
5479

5580
# setup npm cache in a local directory
5681
cat <<EOT > .npmrc
@@ -63,4 +88,4 @@ EOT
6388

6489
# install node dependencies
6590
npm install # npm prepare runs after install and will compile the library
66-
nvm use ${NODE_VERSION} # Switch to the node version we want to test against
91+
nvm use "${NODE_VERSION}" # Switch to the node version we want to test against

0 commit comments

Comments
 (0)