nvm是管理node版本的一个工具,具体介绍不再赘述,请到GitHub(https://github.com/creationix/nvm)查看。
安装
Linux / Mac
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
或
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
然后执行source ~/.bashrc
windows
windows是单独的一个GitHub(https://github.com/coreybutler/nvm-windows/releases),
下载地址:https://github.com/coreybutler/nvm-windows/releases
分为nvm-noinstall.zip和nvm-setup.zip,根据自己情况选择。
配置
安装好以后,先下载一个最新版本的node试试。
nvm install latest
下载完成后,查看node是否安装成功
node -v
再查看npm是否安装成功
npm -v
如果npm提示找不到,可能由于国内下载速度慢,这时需要配置国内镜像了。
windows:找到nvm安装目录,打开根目录下的setting.txt文件,追加淘宝镜像
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
linux / mac:
在 .bash_profile
中追加
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
这时重新下载node版本就可以了。
常用命令
nvm list 列出所有安装的版本
nvm install <version> 安装版本
nvm uninstall <version> 卸载版本
nvm use <version> 使用版本