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 # 第二次安装就会从缓存下载了,速度很快
相关文章
相关标签/搜索