From 09483f422e074379908b175af84a50ba4ac00844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 29 Oct 2011 09:39:30 +0200 Subject: [PATCH 1/8] [feature] Add `run` command `run` command runs given node version without modyfing global state: [maciej@PC07 nvm (run)]$ node --version v0.4.12 [maciej@PC07 nvm (run)]$ nvm run 0.4.12 Running node v0.4.12 > process.version 'v0.4.12' > [maciej@PC07 nvm (run)]$ nvm run 0.5.9 Running node v0.5.9 > process.version 'v0.5.9' > [maciej@PC07 nvm (run)]$ node --version v0.4.12 --- nvm.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nvm.sh b/nvm.sh index e9aa070..5fae69f 100755 --- a/nvm.sh +++ b/nvm.sh @@ -200,6 +200,20 @@ nvm() export NVM_BIN="$NVM_DIR/$VERSION/bin" echo "Now using node $VERSION" ;; + "run" ) + # run given version of node + if [ $# -ne 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 node $VERSION" + $NVM_DIR/$VERSION/bin/node + ;; "ls" | "list" ) if [ $# -ne 1 ]; then nvm_version $2 From 335a25332388edef7f7ff5f63a27c0c467a610c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 29 Oct 2011 10:04:37 +0200 Subject: [PATCH 2/8] [docs] Document `run` command --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 09c4d1d..fe5be56 100644 --- a/README.markdown +++ b/README.markdown @@ -27,6 +27,10 @@ And then in any new shell just use the installed version: nvm use v0.4.1 +Or you can just run it: + + nvm run v0.4.1 + If you want to see what versions are available: nvm ls From 53e1764a8a397539ce2a0c13b2b2532c86e9cbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 5 Nov 2011 17:32:17 +0100 Subject: [PATCH 3/8] [feature] Allow passing additional arguments to node For example: nvm run v0.6.0 myApp.js --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 5fae69f..c4e6596 100755 --- a/nvm.sh +++ b/nvm.sh @@ -202,7 +202,7 @@ nvm() ;; "run" ) # run given version of node - if [ $# -ne 2 ]; then + if [ $# -lt 2 ]; then nvm help return fi @@ -212,7 +212,7 @@ nvm() return; fi echo "Running node $VERSION" - $NVM_DIR/$VERSION/bin/node + $NVM_DIR/$VERSION/bin/node "${@:3}" ;; "ls" | "list" ) if [ $# -ne 1 ]; then From 0700d140653c4690d5cecd8237f4450284c3598a Mon Sep 17 00:00:00 2001 From: alessioalex Date: Mon, 14 Nov 2011 15:48:56 +0200 Subject: [PATCH 4/8] Remove downloads from /src if installation failed --- README.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.markdown b/README.markdown index 09c4d1d..3d3d02e 100644 --- a/README.markdown +++ b/README.markdown @@ -39,3 +39,8 @@ To set a default Node version to be used in any new shell, use the alias 'defaul nvm alias default v0.4.1 +## Problems + +If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following: + + curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume. From 629b51ebf1284694e91eb5936b1aabbc421dbb32 Mon Sep 17 00:00:00 2001 From: alessioalex Date: Mon, 14 Nov 2011 16:16:09 +0200 Subject: [PATCH 5/8] alias node for sudoers in documentation --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 3d3d02e..c9e4ea5 100644 --- a/README.markdown +++ b/README.markdown @@ -44,3 +44,7 @@ To set a default Node version to be used in any new shell, use the alias 'defaul If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following: curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume. + +Where's my 'sudo node'? Checkout this link: + + https://github.com/creationix/nvm/issues/43 From 269bb008fc66602cb5fd97a862fb7d04badc9dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Mon, 14 Nov 2011 19:35:55 +0100 Subject: [PATCH 6/8] [doc] Update help --- nvm.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvm.sh b/nvm.sh index f049d87..ba25641 100755 --- a/nvm.sh +++ b/nvm.sh @@ -66,6 +66,7 @@ nvm() echo " nvm install Download and install a " echo " nvm uninstall Uninstall a version" echo " nvm use Modify PATH to use " + echo " nvm run [] Run with as arguments" echo " nvm ls List installed versions" echo " nvm ls List versions matching a given description" echo " nvm deactivate Undo effects of NVM on current shell" @@ -77,6 +78,7 @@ nvm() echo "Example:" echo " nvm install v0.4.12 Install a specific version number" echo " nvm use 0.2 Use the latest available 0.2.x release" + echo " nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12" echo " nvm alias default 0.4 Auto use the latest installed v0.4.x version" echo ;; From 990ad81419441d6a4f21b0d87b9232d246d45e03 Mon Sep 17 00:00:00 2001 From: "Jeffrey D. Van Alstine" Date: Thu, 17 Nov 2011 15:38:51 -0700 Subject: [PATCH 7/8] Check if node v0.1.x or v0.2.x before npm installs --- nvm.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index ba25641..debd227 100755 --- a/nvm.sh +++ b/nvm.sh @@ -115,7 +115,13 @@ nvm() if ! which npm ; then echo "Installing npm..." # TODO: if node version 0.2.x add npm_install=0.2.19 before sh - curl http://npmjs.org/install.sh | clean=yes sh + if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then + echo "npm requires node v0.2.x or higher" + elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then + curl http://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh + else + curl http://npmjs.org/install.sh | clean=yes sh + fi fi else echo "nvm: install $VERSION failed!" From 18f4064003083685495687acd4e237721e6d1649 Mon Sep 17 00:00:00 2001 From: "Jeffrey D. Van Alstine" Date: Thu, 17 Nov 2011 16:15:31 -0700 Subject: [PATCH 8/8] Fixes npm version check for node v0.2.0, v0.2.1 and v0.2.2 --- nvm.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index debd227..6d589d8 100755 --- a/nvm.sh +++ b/nvm.sh @@ -114,11 +114,14 @@ nvm() nvm use $VERSION if ! which npm ; then echo "Installing npm..." - # TODO: if node version 0.2.x add npm_install=0.2.19 before sh if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then - echo "npm requires node v0.2.x or higher" + echo "npm requires node v0.2.3 or higher" elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then - curl http://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh + if [[ "`expr match $VERSION '\(^v0\.2\.[0-2]$\)'`" != '' ]]; then + echo "npm requires node v0.2.3 or higher" + else + curl http://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh + fi else curl http://npmjs.org/install.sh | clean=yes sh fi