Skip to content

Commit

Permalink
[Fix] nvm_install_latest_npm: avoid unbound variable
Browse files Browse the repository at this point in the history
Fixes #3447
  • Loading branch information
ljharb committed Oct 23, 2024
1 parent 5dc31ac commit 6b70c40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ nvm_install_latest_npm() {
nvm_echo 'Attempting to upgrade to the latest working version of npm...'
local NODE_VERSION
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
local NPM_VERSION
NPM_VERSION="$(npm --version 2>/dev/null)"

if [ "${NODE_VERSION}" = 'system' ]; then
NODE_VERSION="$(node --version)"
elif [ "${NODE_VERSION}" = 'none' ]; then
Expand All @@ -206,8 +209,6 @@ nvm_install_latest_npm() {
nvm_err 'Unable to obtain node version.'
return 1
fi
local NPM_VERSION
NPM_VERSION="$(npm --version 2>/dev/null)"
if [ -z "${NPM_VERSION}" ]; then
nvm_err 'Unable to obtain npm version.'
return 2
Expand Down

0 comments on commit 6b70c40

Please sign in to comment.