1.为什么需要版本控制管理
在工作中,每个项目的需求不同,进而不同项目需要使用不同版本的NodeJS运行环境,这种情况下,对于维护多个版本的node将会是一件非常麻烦的事情,nvm就是为解决这个问题而产生的。
2.下载地址
https://pan.baidu.com/s/1ymy6e-OjlTba4SvbHp8Bzw?pwd=1028
3.nvm的常用命令
nvm off // 禁用node.js版本管理(不卸载任何东西)
nvm on // 启用node.js版本管理
nvm install <version> // 安装node.js的命名 version是版本号 例如:nvm install 8.12.0
nvm uninstall <version> // 卸载node.js是的命令,卸载指定版本的nodejs,当安装失败时卸载使用
nvm ls // 显示所有安装的node.js版本
nvm list available // 显示可以安装的所有node.js的版本
nvm use <version> // 切换到使用指定的nodejs版本
nvm v // 显示nvm版本
nvm install stable // 安装最新稳定版
4.其他说明
#node版本
ps:
https://nodejs.org/en/download/releases
记得设置快捷方式
e.g:
nvm install 14.21.3
nvm use 14.21.3
#npm config配置
#设置全局包目录
npm config set prefix=D:\develop\nvm\node_global
#设置缓存目录
npm config set cache=D:\develop\nvm\node_cache
#设置镜像地址(淘宝最新地址https://registry.npmmirror.com)
npm config set registry=https://registry.npm.taobao.org
或者
npm config set registry=https://registry.npmmirror.com
#设置strict-ssl
npm config set registry=false
# 修改nvm 目录下settings.txt文件
root: D:\develop\nvm\nvm
path: D:\develop\nvm\nodejs
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
5.传统安装
NODE_PATH
D:\develop\nodejs
Path 添加
%NODE_PATH%\node_cache
%NODE_PATH%\node_global
D:\develop\nodejs
npmrc
prefix=D:\develop\nodejs\node_global
cache=D:\develop\nodejs\node_cache
https://blog.csdn.net/qq_45824905/article/details/124820553