nvm:NodeJs版本管理工具下载安装与使用教程
nvm是什么nvm是一个node的版本管理工具可以简单操作node版本的切换、安装、查看。。。等等与npm不同的是npm是依赖包的管理工具。nvm特点node是一个基于 Chrome V8 引擎的 JS 运行环境。npm是 node.js 默认的包管理系统用 JavaScript 编写的在安装的 node 的时候npm 也会跟着一起安装管理 node 中的第三方插件。nvmnode 版本管理器也就是说一个 nvm 可以管理多个 node 版本包含 npm 与 npx可以方便快捷的 安装、切换 不同版本的 node。如何下载官方网址https://www.nvmnode.comwindows下载exe安装Linux/MacOS/WSLLinux 和 MacOS 使用的是原始的 nvm-sh/nvm 版本。安装方法您可以通过以下命令之一安装 NVMcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash或者wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash中国大陆加速方法curl -o- https://hub.gitmirror.com/raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash或者wget -qO- https://hub.gitmirror.com/raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/instalnvm常用命令nvm list available查看可在线安装的NodeJS版本nvm ls列出所有已经在NVM中安装的NodeJS版本。nvm current显示当前正在使用的Node版本。nvm install xx.xx.xx在NVM中在线安装指定版本的NodeJSxx.xx.xx为指定的版本号。nvm uninstall xx.xx.xx在NVM中卸载指定版本的NodeJSxx.xx.xx为指定的版本号。nvm use xx.xx.xx切换NodeJS版本xx.xx.xx为指定的版本号。nvm version显示当前所使用的NVM的版本号。其它命令如nvm arch、nvm on、nvm off、nvm proxy、nvm node_mirror、nvm npm_mirror、nvm root等npm在国内存在下载速度比较慢的问题。为解决这个问题需要切换npm下载源为国内的镜像源npm国内下载镜像汇总npm官方原始镜像: https://registry.npmjs.org/淘宝npm镜像http://registry.npmmirror.com阿里云npm镜像: https://npm.aliyun.com腾讯云npm镜像: https://mirrors.cloud.tencent.com/npm/华为云npm镜像: https://mirrors.huaweicloud.com/repository/npm/网易npm镜像: https://mirrors.163.com/npm/中科大开源镜像站: http://mirrors.ustc.edu.cn/清华大学开源镜像站: https://mirrors.tuna.tsinghua.edu.cn/查看当前使用的npm镜像源使用命令npm config get registry切换npm镜像源使用命令npm config set registry http://mirrors.cloud.tencent.com/npm/切换为国内的镜像源之后确认是否切换成功查看当前使用的npm镜像命令npm config get registry以上命令运行效果如图使用nrm管理镜像源nrm是一个npm源管理工具可以使用nrm切换不同的镜像源先恢复官方的镜像源使用命令npm config set registry https://registry.npmjs.org/安装nrm命令npm install -g nrm使用nrm查看有哪些npm镜像源, 命令nrm ls运行命令会得到类似以下结果的输出npm ---- https://registry.npmjs.org/yarn ---- https://registry.yarnpkg.com/tencent - https://mirrors.cloud.tencent.com/npm/huawei -- https://repo.huaweicloud.com/repository/npm/使用nrm切换npm镜像源需要用到nrm ls命令中得到的结果命令如下nrm npmMirror恢复官方源运行命令npm config set registry https://registry.npmjs.org/