NVM介绍
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Windows 下载与安装
直接访问传送门,选择nvm-setup.zip。下载后直接安装皆可
Linux使用 nvm 安装 node 环境
- 运行命令,安装 nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
- 查看 nvm 配置文件是生成,可以查看 .bash_profile / .bashrc 文件,查看下配置信息写入了那个文件,然后运行命令,是配置生效,运行命令安装相应的 node 版本即可
source .bashrc
验证安装
打开命令行,直行 nvm -v 命令
常用命令
nvm install 安装指定版本,可模糊安装
安装v4.4.0,既可nvm install v4.4.0,又可nvm install 4.4
nvm uninstall 删除已安装的指定版本
nvm use 切换使用指定版本的node
nvm ls 列出所有安装的版本
nvm ls-remote 列出所有远程服务器的版本
nvm current 显示当前的版本
nvm alias 给不同的版本添加别名
nvm unalias 删除已定义的别名
nvm reinstall-packages 在当前版本node环境下,重新全局安装指定版本号的npm包