使用node版本管理工具nvm,轻松快速切换node版

611 阅读1分钟

使用 nvm(Node Version Manager)可以方便地在您的系统中管理 Node.js 的不同版本。

1.安装 nvm

在 Linux 或 macOS 上,可以使用以下命令安装 nvm:

curl -o- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh> | bash

在 Windows 上,可以下载并运行官方安装程序。

2.使用 nvm 安装 Node.js 非常简单,只需运行以下命令:

nvm install <version>

其中 是要安装的 Node.js 版本号,例如:

nvm install 16.10.0

3.切换 Node.js 版本

使用以下命令可以切换当前正在使用的 Node.js 版本:

nvm use <version>

例如,要使用安装的 16.10.0 版本的 Node.js,可以运行以下命令:

nvm use 16.10.0

4.查看已安装的 Node.js 版本

可以使用以下命令查看已经安装的 Node.js 版本:

nvm ls

5.卸载 Node.js

要卸载特定版本的 Node.js,请使用以下命令:

nvm uninstall <version>

例如,要卸载 16.10.0 版本的 Node.js,可以运行以下命令:

nvm uninstall 16.10.0