Skip to content

Commit 6b70c40

Browse files
committed
[Fix] nvm_install_latest_npm: avoid unbound variable
Fixes #3447
1 parent 5dc31ac commit 6b70c40

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: nvm.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ nvm_install_latest_npm() {
196196
nvm_echo 'Attempting to upgrade to the latest working version of npm...'
197197
local NODE_VERSION
198198
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
199+
local NPM_VERSION
200+
NPM_VERSION="$(npm --version 2>/dev/null)"
201+
199202
if [ "${NODE_VERSION}" = 'system' ]; then
200203
NODE_VERSION="$(node --version)"
201204
elif [ "${NODE_VERSION}" = 'none' ]; then
@@ -206,8 +209,6 @@ nvm_install_latest_npm() {
206209
nvm_err 'Unable to obtain node version.'
207210
return 1
208211
fi
209-
local NPM_VERSION
210-
NPM_VERSION="$(npm --version 2>/dev/null)"
211212
if [ -z "${NPM_VERSION}" ]; then
212213
nvm_err 'Unable to obtain npm version.'
213214
return 2

0 commit comments

Comments
 (0)