Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
sudo pacman -S nvm
不知道为什么使用pacman安装的nvm,是找不到命令的,所以我还是使用脚本安装。
使用脚本安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/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).
To download, compile, and install the latest release of node, do this:
nvm install node # "node" is an alias for the latest version
To install a specific version of node:
nvm install 14.7.0 # or 16.3.0, 12.22.1, etc
And then in any new shell just use the installed version:
nvm use node
Or you can just run it:
nvm run node --version
Or, you can run any arbitrary command in a subshell with the desired version of node:
nvm exec 4.2 node --version
You can also get the path to the executable to where it was installed:
nvm which 12.22
If you want to see what versions are installed:
nvm ls
If you want to see what versions are available to install:
nvm ls-remote