File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 1
1
#! /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.
4
9
5
10
NODE_ARTIFACTS_PATH=" ${PROJECT_DIRECTORY} /node-artifacts"
6
11
if [[ " $OS " == " Windows_NT" ]]; then
7
12
NODE_ARTIFACTS_PATH=$( cygpath --unix " $NODE_ARTIFACTS_PATH " )
8
13
fi
9
14
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 "
11
19
hash -r
12
20
13
21
export NODE_OPTIONS=" --trace-deprecation --trace-warnings"
Original file line number Diff line number Diff line change 2
2
set -o errexit # Exit the script with error if any of the commands fail
3
3
4
4
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 "
7
7
8
8
CURL_FLAGS=(
9
9
--fail # Exit code 1 if request fails
90
90
mv " ${NODE_ARTIFACTS_PATH} /${node_directory} " " ${NODE_ARTIFACTS_PATH} /nodejs"
91
91
fi
92
92
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
100
97
101
98
# Cannot upgrade npm version for node 12
102
99
if [[ $operating_system != " win" ]] && [[ $NODE_LTS_VERSION != 12 ]]; then
103
100
# Update npm to latest when we can
104
101
npm install --global npm@latest
105
102
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
110
103
fi
111
104
105
+ echo " npm location: $( which npm) "
112
106
echo " npm version: $( npm -v) "
113
107
114
108
npm install " ${NPM_OPTIONS} "
You can’t perform that action at this time.
0 commit comments