nodejs 版本管理
专栏文章
python我们使用env来管理不同版本之间的切换。nodejs是否有类似的切换版本的方法哪?本文提供一种在mac上快速切换nodejs版本的方法。
n
npm i -g n
sudo n v11
node --versionnvm
nvm(Node Version Manager) node 版本管理工具
安装
- Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash- windows
https://github.com/coreybutler/nvm-windows/releases
使用
source ~/.bashrc
# 查看支持的版本(Linux/macOS 下为 nvm ls-remote;Windows nvm-windows 下为 nvm list available)
nvm ls-remote
# 安装
nvm install 24
# 切换
nvm use 24
# 设置默认版本
nvm alias default 24其他
类似的工具:
- volta 无忧无虑的 JavaScript 工具管理器
# install Volta
curl https://get.volta.sh | bash
# install Node
volta install node
volta install node@16
# start using Node
node