安装
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
配置环境
vim ~/.bashrc
在~/.bashrc的末尾,添加如下语句:
export NVM_DIR="$HOME/.nvm/nvm-0.38.0" [ -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
配置镜像
# 在~/.bashrc中添加
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
# npm配置淘宝镜像
npm config set registry https://registry.npm.taobao.org
之后运行
source ~/.bashrc
使用
使用NVM安装node v8.16.0
nvm install 8.16.0
切换node版本
nvm use 14.17.3
标签:npm,linux,bashrc,bash,使用,nvm,NVM,DIR
From: https://www.cnblogs.com/llk2000/p/16845977.html