Skip to main content

npm安装nrm来管理和快速切换npm下载源

· 预计阅读时间:1 分钟
Tags:npmnrm
摘要

npm的默认下载源是在国外的,在国内使用默认的下载源时速度会非常的慢;然而我们可以通过切换成国内的下载源比如taobao进行下载安装npm包;本文将讲一下怎么通过nrm管理切换npm的下载源

安装nrm#

全局安装nrm

npm i nrm -g

查看npm的下载源#

通过nrm的命令查看npm的下载源

nrm ls

输出的下载源列表,带*号的表示当前使用的下载源

* npm -------- https://registry.npmjs.org/  yarn ------- https://registry.yarnpkg.com/  cnpm ------- http://r.cnpmjs.org/  taobao ----- https://registry.npm.taobao.org/  nj --------- https://registry.nodejitsu.com/  npmMirror -- https://skimdb.npmjs.com/registry/  edunpm ----- http://registry.enpmjs.org/

切换下载源#

通过nrm的命令切换npm的下载源为taobao

nrm use taobao

如下输出即切换成功

 Registry has been set to: https://registry.npm.taobao.org/