From 383f39ab613c7417be11be3891dfde331da8ecb6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 29 Nov 2014 08:52:09 -0800 Subject: [PATCH] Global modules should not be requireable, and `npm root -g` should not be in `$NODE_PATH`. Fixes #586. --- nvm.sh | 9 +-------- ...tivate\" should unset the nvm environment variables." | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/nvm.sh b/nvm.sh index f7e577c..1b0583a 100644 --- a/nvm.sh +++ b/nvm.sh @@ -790,9 +790,7 @@ nvm() { fi NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")" - if [ "$NODE_PATH" = "$NEWPATH" ]; then - echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2 - else + if [ "$NODE_PATH" != "$NEWPATH" ]; then export NODE_PATH="$NEWPATH" echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH" fi @@ -850,13 +848,8 @@ nvm() { MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"` export MANPATH fi - # Strip other version from NODE_PATH - NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` - # Prepend current version - NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"` export PATH hash -r - export NODE_PATH export NVM_PATH="$NVM_VERSION_DIR/lib/node" export NVM_BIN="$NVM_VERSION_DIR/bin" if [ "$NVM_SYMLINK_CURRENT" = true ]; then diff --git "a/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." "b/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." index 2149273..e6a39d4 100755 --- "a/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." +++ "b/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." @@ -8,7 +8,8 @@ die () { echo $@ ; exit 1; } . ../../nvm.sh nvm use v0.2.3 && -[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3" +[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to activate v0.2.3" +# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable nvm deactivate && [ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"