安装nvm — node.js版本管理和切换工具

安装nvm --- node版本管理和切换工具

搞node,要啥nvm啊? Node版本进展迅猛,不同的工程可以支持不同的node版本,如果安装的node版本和工程支持的不同,就需要费时费力的调试了.
nvm用于在电脑上同时安装多个node版本,项目用哪个就切换到哪个,是不是很方便呢?

The npm/Microsoft/Google recommended Node.js version manager for Windows.

NVM的官网介绍,是NPM官方/微软/谷歌推荐的Windows 上node版本管理工具,就问你牛不牛??

下载nvm安装包

nvm下载地址 直接github下载下来. 写文章时版本为1.17,也可以直接点击下载

nvm1.17下载包

下载完,点击安装即可.

建议将nvm以及node的路径指定为非默认路径,这样后面维护好找些.

卸载已经安装的node

为了使用nvm正常管理node,需要先卸载之前安装的任何node版本. 旧的不去新的不来??.

使用nvm 安装需要的node版本

安装完成后,重新打开一个powershell或者cmd窗口,执行nvm就可以了

?E:\codesλ nvm listNo installations recognized.?E:\codes

可以看到nvm命令可以正常的运行了,先安装个node 8.x版本看看

?E:\codesλ nvm install 8.16.0Downloading node.js version 8.16.0 (64-bit)...CompleteCreating E:\node\nvm\tempDownloading npm version 6.4.1... CompleteInstalling npm v6.4.1...Installation complete. If you want to use this version, typenvm use 8.16.0?E:\codesλ nvm use 8.16.0Now using node v8.16.0 (64-bit)?E:\codes λ node --versionv8.16.0?E:\codes

库上有哪些版本可以使用呢,一行命令可以方便的得知:

E:\codesλ nvm list available| CURRENT | LTS | OLD STABLE | OLD UNSTABLE ||--------------|--------------|--------------|--------------|| 13.12.0 | 12.16.1 | 0.12.18 | 0.11.16 || 13.11.0 | 12.16.0 | 0.12.17 | 0.11.15 || 13.10.1 | 12.15.0 | 0.12.16 | 0.11.14 || 13.10.0 | 12.14.1 | 0.12.15 | 0.11.13 || 13.9.0 | 12.14.0 | 0.12.14 | 0.11.12 || 13.8.0 | 12.13.1 | 0.12.13 | 0.11.11 || 13.7.0 | 12.13.0 | 0.12.12 | 0.11.10 || 13.6.0 | 10.19.0 | 0.12.11 | 0.11.9 || 13.5.0 | 10.18.1 | 0.12.10 | 0.11.8 || 13.4.0 | 10.18.0 | 0.12.9 | 0.11.7 || 13.3.0 | 10.17.0 | 0.12.8 | 0.11.6 || 13.2.0 | 10.16.3 | 0.12.7 | 0.11.5 || 13.1.0 | 10.16.2 | 0.12.6 | 0.11.4 || 13.0.1 | 10.16.1 | 0.12.5 | 0.11.3 || 13.0.0 | 10.16.0 | 0.12.4 | 0.11.2 || 12.12.0 | 10.15.3 | 0.12.3 | 0.11.1 || 12.11.1 | 10.15.2 | 0.12.2 | 0.11.0 || 12.11.0 | 10.15.1 | 0.12.1 | 0.9.12 || 12.10.0 | 10.15.0 | 0.12.0 | 0.9.11 || 12.9.1 | 10.14.2 | 0.10.48 | 0.9.10 |This is a partial list. For a complete list, visit https://nodejs.org/download/release

使用nvm 切换不同的node版本

再安装个新的 12.12版本看看,为什么安装这个版本? 因为这个版本号好记...

λ nvm install 12.12.0Downloading node.js version 12.12.0 (64-bit)...CompleteCreating E:\node\nvm\tempDownloading npm version 6.11.3... CompleteInstalling npm v6.11.3...Installation complete. If you want to use this version, typenvm use 12.12.0?E:\codesλ nvm use 12.12.0Now using node v12.12.0 (64-bit)?E:\codesλ node --versionv12.12.0?E:\codesλ nvm use 8.16.0Now using node v8.16.0 (64-bit)?E:\codesλ node --versionv8.16.0?E:\codesλ

可以看到 nvm use 可以随意的切换node 版本,真是太方便了!!!

走过路过不错过,这里就是子午哥;追根究底寻根源,问题解决没的说

本篇文章由一文多发平台PDArtPub自动发布

相关文章