[Fix] `nvm_print_npm_version`: if `npm` exists but its node crashes, do not print the npm version

Jordan Harband 2023-04-28 10:57:57 -07:00
parent a07cd41af1
commit c08b38a2a4
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 5 additions and 1 deletions

6
nvm.sh
View File

@ -163,7 +163,11 @@ nvm_is_version_installed() {
nvm_print_npm_version() {
if nvm_has "npm"; then
command printf " (npm v$(npm --version 2>/dev/null))"
local NPM_VERSION
NPM_VERSION="$(npm --version 2>/dev/null)"
if [ -n "${NPM_VERSION}" ]; then
command printf " (npm v${NPM_VERSION})"
fi
fi
}