使用Sinopia搭建私有npm仓库
2017-06-16 20:22
239 查看
使用Sinopia搭建私有npm仓库
在用npm装包的时候,每次都要下载一大堆,慢且不说,npm还老被墙,所以就想到在公司内部搭建npm仓库镜像。大概看了几个,觉得Sinopia最简单也好用,所以就使用Sinopia搭建仓库吧。安装
sudo npm install -g sinopia
配置与运行
安装完成后,暂时不知道配置文件在哪里,可以先运行一下 sinopia,比如:$ sinopia warn --- config file - /home/<user>/.config/sinopia/config.yaml warn --- http address - http://localhost:4873/[/code]
从上面命令输出可以看到配置文件路径:/home//.config/sinopia/config.yaml
下面修改配置文件,在最后加上一行 “listen: 0.0.0.0:4873”,目的是为了可以从别的机器上也能访问 sinopia 仓库。# # This is the default config file. It allows all users to do anything, # so don't use it on production systems. # # Look here for more config file examples: # https://github.com/rlidwka/sinopia/tree/master/conf # # path to a directory with all packages storage: /home/jhadmin/.local/share/sinopia/storage auth: htpasswd: file: ./htpasswd # Maximum amount of users allowed to register, defaults to "+inf". # You can set this to -1 to disable registration. #max_users: 1000 # a list of other known repositories we can talk to uplinks: npmjs: url: https://registry.npmjs.org/ packages: '@*/*': # scoped packages access: $all publish: $authenticated '*': # allow all users (including non-authenticated users) to read and # publish all packages # # you can specify usernames/groupnames (depending on your auth plugin) # and three keywords: "$all", "$anonymous", "$authenticated" access: $all # allow all known users to publish packages # (anyone can register by default, remember?) publish: $authenticated # if package is not available locally, proxy requests to 'npmjs' registry proxy: npmjs # log settings logs: - {type: stdout, format: pretty, level: info} #- {type: file, path: sinopia.log, level: info} listen: 0.0.0.0:4873
修改完成后再次启动 Sinopia 服务,如下:$ sinopia warn --- config file - /home/<user>/.config/sinopia/config.yaml warn --- http address - http://0.0.0.0:4873/[/code]使用
私有仓库已经有了,下面来看看怎么使用,这里我们使用了nrm来管理私有仓库。(可以参考我的前一篇博客)添加私有仓库
$ nrm add mynpm http://192.168.0.123:4873[/code]使用私有仓库
$ nrm use mynpm测试私有仓库
$ mkdir test $ cd test $ npm install webpack # 第一次安装比较慢 ... $ rm -rf webpack $ npm install webpack # 第二次安装就比较快了 ...
相关文章推荐
- 使用Sinopia搭建私有npm仓库不能下载带有@符号的包
- 【玩转树莓派】使用 sinopia 搭建私有 npm 服务器
- 使用sinopia 搭建私有npm服务器的教程
- 【玩转树莓派】使用 sinopia 搭建私有 npm 服务器
- 【玩转树莓派】使用 sinopia 搭建私有 npm 服务器
- 使用cnpm搭建私有NPM仓库 发布npm包
- 使用cnpm搭建企业内部私有NPM仓库
- 使用cnpm搭建企业内部私有NPM仓库
- 使用Gradle和Sonatype Nexus 搭建私有maven仓库
- 拥抱 Android Studio 之四:Maven 仓库使用与私有仓库搭建
- 拥抱 Android Studio 之四:Maven 仓库使用与私有仓库搭建
- CocoaPods私有仓库使用和搭建
- CentOS 7 : Docker私有仓库搭建和使用
- 【转】使用sinopia五步快速完成本地npm搭建
- Jenkins 持续集成平台构建之使用nexus搭建maven私有仓库
- 使用Harbor搭建Docker私有镜像仓库服务
- 详解CentOS 7 : Docker私有仓库搭建和使用
- 搭建和使用Docker私有仓库
- 搭建和使用Docker私有仓库
- 使用sinopia搭建自己的npm服务