Global modules should not be requireable, and `npm root -g` should not be in `$NODE_PATH`.

Fixes #586.
master
Jordan Harband 2014-11-29 08:52:09 -08:00
parent 052743816f
commit 383f39ab61
2 changed files with 3 additions and 9 deletions

9
nvm.sh
View File

@ -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

View File

@ -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"