`npm ls` has a bug in some versions when "--parseable --depth=0" is used together.
diff --git a/nvm.sh b/nvm.sh
index 7ed56e0..e45a53e 100644
--- a/nvm.sh
+++ b/nvm.sh
@@ -789,7 +789,7 @@
# declare local INSTALLS first, otherwise it doesn't work in zsh
local INSTALLS
- INSTALLS=$(nvm use $VERSION > /dev/null && npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | xargs)
+ INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
echo "$INSTALLS" | xargs npm install -g --quiet
;;
diff --git a/test/slow/nvm copy-packages/should work as expected b/test/slow/nvm copy-packages/should work as expected
index 66859eb..e599609 100755
--- a/test/slow/nvm copy-packages/should work as expected
+++ b/test/slow/nvm copy-packages/should work as expected
@@ -11,10 +11,10 @@
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
nvm use 0.10.29
-ORIGINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
+ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
nvm copy-packages 0.10.28
-FINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
+FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"