一.安装node
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
中间它会给出:
Append the following lines to the correct file yourself
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
相似的提示,这是要你把这段代码复制到.bash_profile(环境变量文件中),若是没有就建立一个,touch .bash_profile,再打开 open .bash_profile,复制进去就好
二.使用
git
nvm ls-remote
:列出全部能够安装的node版本号
nvm install v10.4.0
:安装指定版本号的node
nvm use v10.3.0
:切换node的版本,这个是全局的
nvm current
:当前node版本
nvm ls
:列出全部已经安装的node版本