nvm 管理 nodejs 版本

nvm 管理 nodejs 版本

安装见github
nstall & Update Script

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

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
  • 显示nodejs已安装版本
    nvm ls
  • 当前node版本
    nvm current
  • 显示远程的lts版本
    nvm ls-remote –lts
  • 安装指定版本
    nvm install vx.x.x
  • 当前环境使用指定版本
    nvm use vx.x.x
  • 长期使用指定版本
    nvm alias default vx.x.x

You must be logged in to post a comment