node 版本管理nvm的安装---mac版
2019-04-11 本文已影响0人
我的昵称好听吗
nvm地址:https://github.com/nvm-sh/nvm
1.安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
或者
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
2.输入“nvm”检查是否安装成功

3.输入nvm后出现 ‘nvm: command not found’ 错误提示:
没有~/.bash_profile
这个文件或者文件中没有相关信息:
在~
路径下创建.base_profile
文件,添加以下内容:
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
我的如下($HOME改为自己的用户路径):

4.使用方法:
(1)安装最新版的node:
nvm install node # "node" is an alias for the latest version
(2)指定下载的node版本
nvm install 6.11.0

(3)查看可以安装的node版本
nvm ls-remote

(4)查看本地用nvm安装过的版本
nvm ls

(4)切换版本
nvm use version
