From 90387bf180bf4bb28ac218fdce5dd0157df0eed9 Mon Sep 17 00:00:00 2001 From: Gabriele Di Stefano Date: Sat, 17 Nov 2012 09:48:23 +0100 Subject: [PATCH] Add support for NPM --- nvm.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nvm.sh b/nvm.sh index 1a193f7..311699b 100755 --- a/nvm.sh +++ b/nvm.sh @@ -155,6 +155,7 @@ nvm() echo " nvm alias [] Show all aliases beginning with " echo " nvm alias Set an alias named pointing to " echo " nvm unalias Deletes the alias named " + echo " nvm npm [] Run NPM within node with as arguments" echo " nvm copy-packages Install global NPM packages contained in to current version" echo echo "Example:" @@ -350,6 +351,20 @@ nvm() echo "Running node $VERSION" $NVM_DIR/$VERSION/bin/node "${@:3}" ;; + "npm" ) + # run npm within the given version of node + if [ $# -lt 2 ]; then + nvm help + return + fi + VERSION=`nvm_version $2` + if [ ! -d $NVM_DIR/$VERSION ]; then + echo "$VERSION version is not installed yet" + return; + fi + echo "Running NPM within node $VERSION" + $NVM_DIR/$VERSION/bin/npm "${@:3}" + ;; "ls" | "list" ) print_versions "`nvm_ls $2`" if [ $# -eq 1 ]; then