赞
踩
为了能够对 Node.js 版本进行版本管理,我整理了 3 款非常实用的 Node.js 版本管理工具,让大家能够自由的切换本地环境不同的 Node.js 版本。
⭐ Github stars: 60K+
nvm[2] 是一款 Node.js 版本管理工具,允许用户通过命令行快速安装、切换和管理不同的 Node.js 版本。
(图片来自:github[3])
nvm 只适用于 macOS 和 Linux 用户的项目,如果是 Windows 用户,可以使用 nvm-windows[4] 、nodist[5] 或 nvs[6] 替换。
macOS 下载方式:
- # 方式1 浏览器打开下面链接下载
- https://github.com/nvm-sh/nvm/blob/v0.39.1/install.sh
- # 下载完成后,通过命令安装
- sh install.sh
-
- # 方式2 推荐
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
-
- # 方式3
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
安装过程中如果遇到一些奇怪的问题,可以查看下 nvm 补充说明[7]。
- nvm ls # 查看版本安装所有版本
- nvm ls-remote # 查看远程所有的 Node.js 版本
- nvm install 17.0.0 # 安装指定的 Node.js 版本
- nvm use 17.0.0 # 使用指定的 Node.js 版本
- nvm alias default 17.0.0 # 设置默认 Node.js 版本
- nvm alias dev 17.0.0 # 设置指定版本的别名,如将 17.0.0 版本别名设置为 dev
⭐ Github stars: 16.7K+
n[8] 是一款交互式的 Node.js 版本管理工具,没有子脚本,没有配置文件,也没有复杂的 API,使用起来非常简单。
n 只适用于 macOS 和 Linux ,不适用于 Windows。
可以使用 npm 直接安装到全局:
npm install n -g
- n # 显示所有已下载版本
- n 10.16.0 # 下载指定版本
- n lts # 查看远程所有 LTS Node.js 版本
- n run 10.16.0 # 运行指定的 Node.js 版本
输入 n -h
查看帮助信息,主要命令如下:
- n Display downloaded Node.js versions and install selection
- n latest Install the latest Node.js release (downloading if necessary)
- n lts Install the latest LTS Node.js release (downloading if necessary)
- n <version> Install Node.js <version> (downloading if necessary)
- n install <version> Install Node.js <version> (downloading if necessary)
- n run <version> [args ...] Execute downloaded Node.js <version> with [args ...]
- n which <version> Output path for downloaded node <version>
- n exec <vers> <cmd> [args...] Execute command with modified PATH, so downloaded node <version> and npm first
- n rm <version ...> Remove the given downloaded version(s)
- n prune Remove all downloaded versions except the installed version
- n --latest Output the latest Node.js version available
- n --lts Output the latest LTS Node.js version available
- n ls Output downloaded versions
- n ls-remote [version] Output matching versions available for download
- n uninstall Remove the installed Node.js
⭐ Github stars: 8.4K+
fnm [9]是一款快速简单
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。