nrm
首先,什么是nrm?
nrm就是npm registry manager 也就是npm的镜像源管理工具,有时候国外资源太慢,那么我们可以用这个来切换镜像源。我们只要通过这个命令: npm install -g nrm 就可以实现安装。
注意-g可以直接放到install的后面,我们以后也最好这样用,因为这样用,我们可以在cmd中上下箭头切换最近命令的时候,容易修改,更方便操作。安装完成后,我们就可以使用了。
命令:nrm ls 用于展示所有可切换的镜像地址
命令:nrm use cnpm 我们这样就可以直接切换到cnpm上了。当然也可以按照上面罗列的其他内容进行切换。
三、nrm切换npm源利器
在使用npm时,官方的源下载npm包会比较慢,国内我们基本使用淘宝的源,最近公司内部搭建了一套npm私有仓库。要添加自己公司内部的npm源,公司内部的源不可能把npm官方的npm包都全量同步,故需要npm源之间的切换,如果使用npm registry xxx的话,太不好管理了。nrm是管理npm源切换的利器。使用方法如下:
安装nrm
npm install -g nrm
nrm --help
Usage: nrm [options] [command]
Commands:
ls list all the registries
current show current registry name
use <registry> change registry to registry
add <registry> <url> [home] add one custom registry
del|rm <registry> delete one custom registry
home <registry> [browser] open the homepage of registry with optional browser
test [registry] show response time for specific or all registries
help print this help
Options:
-h, --help output usage information
-V, --version output the version number
主要使用ls和use命令
1)nrm ls是列出来现在已经配置好的所有的原地址
nrm ls
npm ---- https://registry.npmjs.org/
* cnpm --- http://r.cnpmjs.org/
taobao - http://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn
npmMirror https://skimdb.npmjs.com/registry
2)nrm use是切换到哪个源上
nrm use npm
3)nrm add添加源
4)nrm del删除源
5)nrm test测试源的响应时间,可以作为使用哪个源的参考