Node版本管理器:nvm。简单的bash脚本来管理多个活跃的node.js版本。Installation
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work. Note: nvm does not support Windows (see #284). Two alternatives exist, which are not supported nor developed by us: nvmw nvm-windows Install scriptTo install you could use the install script using cURL:
or Wget:
The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc or ~/.profile). You can customize the install source, directory and profile using the NVM_SOURCE, NVM_DIR, and PROFILE variables. Eg: curl ... | NVM_DIR=/usr/local/nvm bash for a global install. NB. The installer can use git, curl, or wget to download nvm, whatever is available. Manual installFor manual install create a folder somewhere in your filesystem with the nvm.sh file inside it. I put mine in a folder called nvm. Or if you have git installed, then just clone it, and check out the latest version:
To activate nvm, you need to source it from your shell:
I always add this line to my ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login. Often I also put in a line to use a specific version of node. UsageYou can create an .nvmrc file containing version number in the project root directory (or any parent directory).nvm use, nvm install, nvm exec, and nvm run will all respect an .nvmrc file. To download, compile, and install the latest v0.10.x release of node, do this:
And then in any new shell just use the installed version:
Or you can just run it:
Or, you can run any arbitrary command in a subshell with the desired version of node:
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
If you want to use the system-installed version of node, you can use the special default alias "system":
If you want to see what versions are installed:
If you want to see what versions are available to install:
To restore your PATH, you can deactivate it.
To set a default Node version to be used in any new shell, use the alias 'default':
To use a mirror of the node binaries, set $NVM_NODEJS_ORG_MIRROR:
nvm use will not, by default, create a "current"symlink. Set $NVM_SYMLINK_CURRENT to "true" to enable this behavior, which is sometimes useful for IDEs. 项目主页:http://www.open-open.com/lib/view/home/1418097373136 |
小黑屋|在路上
( 蜀ICP备15035742号-1 )
GMT+8, 2025-8-19 02:14
Copyright 2015-2025 djqfx