【node】之nvm的使用

nvm是什么?

你可以把nvm理解为python里面的virtualenv
如果想在同一台机器,同时安装多个版本的node.js,就需要用到版本管理工具nvm。

http://javascript.ruanyifeng.com/nodejs/basic.html#toc6

安装nvm

  1. 使用git克隆下来
    cd ~/ from anywhere then git clone https://github.com/nvm-sh/nvm.git .nvm
  2. 切换到指定分支
    cd ~/.nvm and check out the latest version with git checkout v0.34.0
  3. 激活nvm
    activate nvm by sourcing it from your shell: . nvm.sh
  4. 在.bash_profile中添加指定内容
    Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

使用

下载指定版本node
nvm install v10.15.3
使用指定版本node
nvm use v10.15.3

查看版本号

node -v
v10.15.3
npm -v
6.4.1
which node
~/.nvm/versions/node/v10.15.3/bin/node

which npm
~/.nvm/versions/node/v10.15.3/bin/npm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值