使用 nrm 管理 npm 源
2026-03-10 by dongnan
什么是 nrm?
简单来说,nrm (npm registry manager) 是一个专门用来管理和切换 npm 镜像源的命令行工具。
如果你经常需要在官方源、阿里云源、公司私服源之间切换,nrm 就是你的“一键切换开关”
环境描述
$ head -n1 /etc/os-release
PRETTY_NAME="Ubuntu 22.04.5 LTS"
$ nvm -v
0.39.7
$ node -v
v24.13.0
$ npm -v
11.6.2
$ pnpm -v
8.11.0
默认源
npm config get registry
https://registry.npmjs.org/
当然可以手动切换国内镜像源
npm config set registry https://registry.npmmirror.com
使用 nrm 管理镜像源
频繁切换,优先使用 nrm:
安装
npm install -g nrm
查看
nrm ls
* npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
huawei ------- https://repo.huaweicloud.com/repository/npm/
测试速度
nrm test
npm ---------- 887 ms
yarn --------- 812 ms
tencent ------ 454 ms
cnpm --------- timeout (Fetch timeout over 5000 ms)
* taobao ------- 122 ms
npmMirror ---- 1134 ms (Fetch error, xxx, please ignore)
huawei ------- 1240 ms
切换
nrm use taobao
SUCCESS The registry has been changed to 'taobao'.
验证
测试最火爆的小龙虾,秒装 666:
pnpm install -g openclaw@latest
参考
- Gemini