公司一般只会用某个版本的Node,自己想体验一下高版本的特性,所以想在windows上安装两个版本的node。NPM不行,所以选择的的NVM(Node Version Management)来管理多个Node版本。
1.NVM下载链接
https://github.com/coreybutler/nvm-windows/releases
2.下载、解压后是.exe文件,双击执行即可。
若当前有通过NPM安装的Node版本,NVM在安装过程中会安装一个对应的自己管理的版本。(这个在安装完之后可以在安装目录中看到)
3.设置代理(如果公司有代理需要设置)(from https://github.com/creationix/nvm/issues/973)
具体IP什么的可以查看之前NPM设置过的代理.npmrc文件
export http_proxy=username:password@proxy-server-your-company.com:port
export https_proxy=username:password@proxy-server-your-company.com:port
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
4.如果没有代理,跳过第三步
通过nvm install <指定的node版本>。eg. nvm install 6.7.0
6. 上面的 nvm use xxx版本是当前window的默认全局版本
若是IDE,则可以自己指定相关版本
5. NVM相关命令
For linux :
reference:
1. https://github.com/creationix/nvm --git install
2.http://blog.sina.com.cn/s/blog_a3fb1fe30102wgrk.html
If you have git
installed (requires git v1.7.10+):
- clone this repo in the root of your user profile
cd ~/
from anywhere thengit clone https://github.com/creationix/nvm.git .nvm
cd ~/.nvm
and check out the latest version withgit checkout v0.33.11
- activate nvm by sourcing it from your shell:
. nvm.sh
4. 配置终端启动时自动执行 source ~/git/nvm/nvm.sh,
在 ~/.bashrc, ~/.bash_profile, ~/.profile, 或者 ~/.zshrc 文件添加以下命令:
source ~/git/nvm/nvm.sh