node之sinopia搭建本地npm仓库

 
场景: 因为公司是内网网络,很多nodejs的业务服务器无法访问外网,那搭建本地npm仓库就很有必要。(ps: sinopia是可以上外网的)
 
搭建sinopia-server,npm本地緩存倉庫
倉庫服務器:10.134.171.55
端口:4873
 
原理:
以sinopia搭建本地npm仓库,作用是缓存客户端的下载过的npm模块,二次下载的话,不需要外网下载!
 

首先,客戶端安装nrm(npm管理工具):    
npm install  -g nrm
nrm add  local http://10.134.171.55:4873
nrm use  local
 
验证:
 
 
$ nrm --help # 查看nrm命令帮助
$ nrm list # 列出可用的 npm 镜像地址
$ nrm use taobao # 使用`淘宝npm`镜像地址
 
測試方法:
安装完成.之后你通过npm install 安装的包,sinopia都会帮你缓存到本地了.试一下吧。
mkdir test && cd test
npm install lodash # sinopia发现本地没有 lodash包,就会从 taobao镜像下载
rm -rf node-modules # 删除目录
npm insatll lodash # 第二次安装就会从缓存下载了,速度很快
 
posted @ 2018-07-14 18:32    阅读(1935)  评论(0编辑  收藏  举报