Skip to content

Commit

Permalink
Global modules should not be requireable, and npm root -g should no…
Browse files Browse the repository at this point in the history
…t be in `$NODE_PATH`.

Fixes #586.
  • Loading branch information
ljharb committed Nov 29, 2014
1 parent 0527438 commit 383f39a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
9 changes: 1 addition & 8 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 383f39a

Please sign in to comment.