Skip to content

Commit db98f8c

Browse files
committed
[Fix] install-latest-npm: npm 6 is out, and requires node 6 or higher
1 parent 1b14e6b commit db98f8c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

nvm.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,29 @@ nvm_install_latest_npm() {
206206
NVM_IS_4_4_OR_BELOW=1
207207
fi
208208

209+
local NVM_IS_5_OR_ABOVE
210+
NVM_IS_5_OR_ABOVE=0
211+
if [ $NVM_IS_4_4_OR_BELOW -eq 0 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 5.0.0; then
212+
NVM_IS_5_OR_ABOVE=1
213+
fi
214+
215+
local NVM_IS_6_OR_ABOVE
216+
NVM_IS_6_OR_ABOVE=0
217+
if [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 6.0.0; then
218+
NVM_IS_6_OR_ABOVE=1
219+
fi
220+
209221
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || (\
210-
nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 5.0.0 \
211-
&& nvm_version_greater 5.10.0 "${NODE_VERSION}"\
222+
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"\
212223
); then
213224
nvm_echo '* `npm` `v5.3.x` is the last version that works on `node` 4.x versions below v4.4, or 5.x versions below v5.10, due to `Buffer.alloc`'
214225
$NVM_NPM_CMD install -g [email protected]
215226
elif [ $NVM_IS_4_4_OR_BELOW -eq 0 ] && nvm_version_greater 4.7.0 "${NODE_VERSION}"; then
216227
nvm_echo '* `npm` `v5.4.x` is the last version that works on `node` `v4.5` and `v4.6`'
217228
$NVM_NPM_CMD install -g [email protected]
229+
elif [ $NVM_IS_6_OR_ABOVE -eq 0 ]; then
230+
nvm_echo '* `npm` `v5.x` is the last version that works on `node` below `v6.0.0`'
231+
$NVM_NPM_CMD install -g npm@5
218232
else
219233
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
220234
$NVM_NPM_CMD install -g npm

0 commit comments

Comments
 (0)