Nodejs Version Manager哪個比較好用?
Nodejs Version Manager哪個比較好用?
https://github.com/creationix/nvm
https://github.com/visionmedia/n
哪個比較好用?出了這兩個還有別的嗎?有沒有兼容Windows的?
Node.js 版本管理器比较
在开发过程中,经常需要使用不同版本的 Node.js。因此,选择一个合适的 Node.js 版本管理器是非常重要的。本文将介绍两个常用的 Node.js 版本管理器,并提供一些基本的使用示例。
1. nvm (Node Version Manager)
nvm
是一个非常流行的 Node.js 版本管理工具,主要用于 macOS 和 Linux 系统。它允许你轻松地安装、卸载和切换不同版本的 Node.js。
安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
或者
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
使用示例
安装特定版本的 Node.js:
nvm install 14.17.0
列出已安装的版本:
nvm ls
切换到指定版本:
nvm use 14.17.0
2. n (Node.js 版本管理器)
n
是另一个轻量级的 Node.js 版本管理工具,同样适用于 macOS 和 Linux。
安装
npm install -g n
使用示例
安装特定版本的 Node.js:
n 14.17.0
安装最新稳定版:
n stable
安装最新测试版:
n latest
兼容 Windows 的版本管理器
对于 Windows 用户,可以考虑使用 nvm-windows
或 nodist
。
-
nvm-windows: 这是一个专门为 Windows 设计的 Node.js 版本管理器。
安装
访问 https://github.com/coreybutler/nvm-windows/releases 下载并安装最新版本。
使用示例
安装特定版本的 Node.js:
nvm install 14.17.0
列出已安装的版本:
nvm list
切换到指定版本:
nvm use 14.17.0
-
nodist: 这也是一个轻量级的 Node.js 版本管理工具,专门为 Windows 设计。
安装
使用 npm 安装:
npm install -g nodist
使用示例
安装特定版本的 Node.js:
nodist install 14.17.0
列出已安装的版本:
nodist list
切换到指定版本:
nodist use 14.17.0
通过上述示例,你可以根据自己的操作系统和需求选择最适合的 Node.js 版本管理器。希望这些信息对你有所帮助!
我一般使用 nvm,因为只需 git clone 到 ~/.nvm 在把 . ~/.nvm/nvm.sh 加到 ~/.bashrc 就搞定了 你看这么简单我完全都记得下来
好像这个是官方的. https://github.com/creationix/nvm
这个的注释好像有点山寨 https://github.com/visionmedia/n
n
My own flavour of node binary management, no subshells, no profile setup, no convoluted api, just simple.