Skip to content

Commit 8c3f9ab

Browse files
apply changes
1 parent 9cde26c commit 8c3f9ab

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

.evergreen/init-node-and-npm-env.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#! /usr/bin/env bash
2-
3-
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
2+
##
3+
## This script add the location of `npm` and `node` to the path.
4+
## This is necessary because evergreen uses separate bash scripts for
5+
## different functions in a given CI run but doesn't persist the environment
6+
## across them. So we manually invoke this script everywhere we need
7+
## access to `npm`, `node`, or need to install something globally from
8+
## npm.
49

510
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
611
if [[ "$OS" == "Windows_NT" ]]; then
712
NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH")
813
fi
914

10-
export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
15+
export NODE_ARTIFACTS_PATH
16+
# npm uses this environment variable to determine where to install global packages
17+
export npm_global_prefix=$NODE_ARTIFACTS_PATH/npm_global
18+
export PATH="$npm_global_prefix/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
1119
hash -r
1220

1321
export NODE_OPTIONS="--trace-deprecation --trace-warnings"

.evergreen/install-dependencies.sh

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -o errexit # Exit the script with error if any of the commands fail
33

44
NODE_LTS_VERSION=${NODE_LTS_VERSION:-12}
5-
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY:-$(pwd)}/node-artifacts"
6-
if [[ "$OS" = "Windows_NT" ]]; then NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH"); fi
5+
6+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
77

88
CURL_FLAGS=(
99
--fail # Exit code 1 if request fails
@@ -90,25 +90,19 @@ else
9090
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs"
9191
fi
9292

93-
export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
94-
hash -r
95-
96-
# Set npm -g prefix to our local artifacts directory
97-
cat <<EOT > .npmrc
98-
prefix=$NODE_ARTIFACTS_PATH/npm_global
99-
EOT
93+
if [[ -z "${npm_global_prefix}" ]]; then
94+
echo "npm_prefix_config not set"
95+
exit 1
96+
fi
10097

10198
# Cannot upgrade npm version for node 12
10299
if [[ $operating_system != "win" ]] && [[ $NODE_LTS_VERSION != 12 ]]; then
103100
# Update npm to latest when we can
104101
npm install --global npm@latest
105102
hash -r
106-
elif [[ $NODE_LTS_VERSION == 12 ]]; then
107-
# Node.js 12 can run up to npm v8
108-
npm install --global npm@8
109-
hash -r
110103
fi
111104

105+
echo "npm location: $(which npm)"
112106
echo "npm version: $(npm -v)"
113107

114108
npm install "${NPM_OPTIONS}"

0 commit comments

Comments
 (0)