Skip to content

Commit c7ca08d

Browse files
committed
[Fix] latest-npm: ensure npm 7 is not installed on node < 10
1 parent 6110d31 commit c7ca08d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nvm.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ nvm_install_latest_npm() {
243243
fi
244244
fi
245245

246+
local NVM_IS_10_OR_ABOVE
247+
NVM_IS_10_OR_ABOVE=0
248+
if [ $NVM_IS_9_3_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 10.0.0; then
249+
NVM_IS_10_OR_ABOVE=1
250+
fi
251+
246252
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {
247253
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \
248254
}; then
@@ -260,6 +266,9 @@ nvm_install_latest_npm() {
260266
; then
261267
nvm_echo '* `npm` `v6.9` is the last version that works on `node` `v6.0.x`, `v6.1.x`, `v9.0.x`, `v9.1.x`, or `v9.2.x`'
262268
$NVM_NPM_CMD install -g [email protected]
269+
elif [ $NVM_IS_10_OR_ABOVE -eq 0 ]; then
270+
nvm_echo '* `npm` `v6.x` is the last version that works on `node` below `v10.0.0`'
271+
$NVM_NPM_CMD install -g npm@6
263272
else
264273
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
265274
$NVM_NPM_CMD install -g npm

0 commit comments

Comments
 (0)