JavaScript npm/nrm 切换安装依赖的镜像源

时间:2025-04-15 10:04:55

nrm: npm registry manager

  • npm 镜像源管理工具

安装nrm

npm install -g nrm

查看所有的镜像源 nrm ls

# 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/

查看当前使用的镜像源

# npm config get registry
https://registry.yarnpkg.com/

切换镜像源

npm use taobao

添加镜像源

npm add registry http://registry.npm.domain.cn/

删除镜像源

nrm del <registry>

测试速度

nrm test npm