mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
Add support for NPM
This commit is contained in:
parent
1709fa9248
commit
90387bf180
15
nvm.sh
15
nvm.sh
@ -155,6 +155,7 @@ nvm()
|
||||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||
echo " nvm npm <version> [<args>] Run NPM within node <version> with <args> as arguments"
|
||||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> 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
|
||||
|
Loading…
Reference in New Issue
Block a user