mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		| @@ -27,6 +27,10 @@ And then in any new shell just use the installed version: | |||||||
|  |  | ||||||
|     nvm use v0.4.1 |     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: | If you want to see what versions are available: | ||||||
|  |  | ||||||
|     nvm ls |     nvm ls | ||||||
| @@ -39,3 +43,12 @@ To set a default Node version to be used in any new shell, use the alias 'defaul | |||||||
|  |  | ||||||
|     nvm alias default v0.4.1 |     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. | ||||||
|  |  | ||||||
|  | Where's my 'sudo node'? Checkout this link: | ||||||
|  |      | ||||||
|  |     https://github.com/creationix/nvm/issues/43 | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -88,6 +88,7 @@ nvm() | |||||||
|       echo "    nvm install <version>       Download and install a <version>" |       echo "    nvm install <version>       Download and install a <version>" | ||||||
|       echo "    nvm uninstall <version>     Uninstall a version" |       echo "    nvm uninstall <version>     Uninstall a version" | ||||||
|       echo "    nvm use <version>           Modify PATH to use <version>" |       echo "    nvm use <version>           Modify PATH to use <version>" | ||||||
|  |       echo "    nvm run <version> [<args>]  Run <version> with <args> as arguments" | ||||||
|       echo "    nvm ls                      List installed versions" |       echo "    nvm ls                      List installed versions" | ||||||
|       echo "    nvm ls <version>            List versions matching a given description" |       echo "    nvm ls <version>            List versions matching a given description" | ||||||
|       echo "    nvm deactivate              Undo effects of NVM on current shell" |       echo "    nvm deactivate              Undo effects of NVM on current shell" | ||||||
| @@ -99,6 +100,7 @@ nvm() | |||||||
|       echo "Example:" |       echo "Example:" | ||||||
|       echo "    nvm install v0.4.12         Install a specific version number" |       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 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 "    nvm alias default 0.4       Auto use the latest installed v0.4.x version" | ||||||
|       echo |       echo | ||||||
|     ;; |     ;; | ||||||
| @@ -134,9 +136,18 @@ nvm() | |||||||
|         nvm use $VERSION |         nvm use $VERSION | ||||||
|         if ! which npm ; then |         if ! which npm ; then | ||||||
|           echo "Installing npm..." |           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.3 or higher" | ||||||
|  |           elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then | ||||||
|  |             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 |             curl http://npmjs.org/install.sh | clean=yes sh | ||||||
|           fi |           fi | ||||||
|  |         fi | ||||||
|       else |       else | ||||||
|         echo "nvm: install $VERSION failed!" |         echo "nvm: install $VERSION failed!" | ||||||
|       fi |       fi | ||||||
| @@ -210,6 +221,20 @@ nvm() | |||||||
|       export NVM_BIN="$NVM_DIR/$VERSION/bin" |       export NVM_BIN="$NVM_DIR/$VERSION/bin" | ||||||
|       echo "Now using node $VERSION" |       echo "Now using node $VERSION" | ||||||
|     ;; |     ;; | ||||||
|  |     "run" ) | ||||||
|  |       # run 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 node $VERSION" | ||||||
|  |       $NVM_DIR/$VERSION/bin/node "${@:3}" | ||||||
|  |     ;; | ||||||
|     "ls" | "list" ) |     "ls" | "list" ) | ||||||
|       print_versions "`nvm_ls $2`" |       print_versions "`nvm_ls $2`" | ||||||
|       if [ $# -eq 1 ]; then |       if [ $# -eq 1 ]; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user