From c08b38a2a46ab7b9fd7d1594b743b8210541e928 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 28 Apr 2023 10:57:57 -0700 Subject: [PATCH] [Fix] `nvm_print_npm_version`: if `npm` exists but its node crashes, do not print the npm version --- nvm.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 1f58c65..a0c451f 100644 --- a/nvm.sh +++ b/nvm.sh @@ -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 }