











官方文档:https://github.com/nvm-sh/nvm
windows版文档:https://github.com/coreybutler/nvm-windows
windows官方下载:https://github.com/coreybutler/nvm-windows/releases
使用命令
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash或
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash如果cloning失败,最大的可能是网络不行,换个网络试试
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执行一下source
bash: source ~/.bashrc
zsh: source ~/.zshrc
ksh: . ~/.profile
注意:推荐使用
~/.bash_profile,执行命令是source ~/.bash_profile
# nvm -v0.38.0查看node列表
# nvm ls v12.22.1 v14.17.1-> v16.3.0default -> node (-> v16.3.0)iojs -> N/A (default)unstable -> N/A (default)node -> stable (-> v16.3.0) (default)stable -> 16.3 (-> v16.3.0) (default)lts/* -> lts/fermium (-> v14.17.1)lts/argon -> v4.9.1 (-> N/A)lts/boron -> v6.17.1 (-> N/A)lts/carbon -> v8.17.0 (-> N/A)lts/dubnium -> v10.24.1 (-> N/A)lts/erbium -> v12.22.1lts/fermium -> v14.17.1这指明了node当前的使用版本是【v16.3.0】
nvm install node # "node" is an alias for the latest versionnvm install 6.14.4 # or 10.10.0, 8.9.1, etc# 查看所有的版本nvm ls-remote# 查看主要的版本,这个比较少信息nvm lsnvm use node使用特定版本的node
nvm use node-version/alias如下:nvm use v14.17.1nvm use 14.17.1nvm use lts/fermium此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。