NPM 私有仓库的搭建
NPM 私有仓库的搭建
为什么搭建私有仓库
balabala,当然是有需求的时候嘛
搭建流程
介绍和安装verdaccio
备注:
程序启动后,配置文件为/home/work/.config/verdaccio/config.yaml
密码文件所在位置:/home/work/.config/verdaccio/htpasswd
日志文件所在文职:/home/work/verdaccio.log
Nodejs环境全局安装(root)
npm install –g verdaccio
pm2 运行程序,注意请切换成普通用户work,不需要root
pm2 start verdaccio
修改配置文件,配置文件如下,
参照默认文件修改内容如下- max_users: -1, 限制用户自行注册
- logs 日记存储方式为文件
- title 修改为公司名称
- 修改packages的访问,发布,取消发布的权限,都改为需要登录的权限,初步限制仅公司内部认证过的账户可访问(access: $authenticated,publish: $authenticated,unpublish: $authenticated,proxy: npmjs)
- 后期需要的话,可针对不同的仓库配置不同的人员username权限,有开发能力的团队,可自行定制插件中间件,比如限制IP和用户名访问
自定义UI界面
从官方ui主题仓库fork到个人帐号,然后克隆到本地开始进行自定义修改
自定义界面后需要发布版本到npm中,根据配置文件的theme设定重启后会自定应用
从官方仓库中fock出来,修改搜索关键字favicon, title, logo等,footer和header也可以修改一下
修改package.json中的name属性,修改为 verdaccio-theme-****
安装依赖,打包,等录npm,发布到npm仓库(可发布到共有npm,也可以发布到刚刚新起的npm私有仓库服务)
npm install && npm run build && npm login && npm publishnpm i verdaccio-theme-**** -g
服务端安装刚刚发布的主题包(root, 全局安装,因为verdaccio是动态加载插件)
最后在配置文件中修改主题配置
theme:
****:
a:b
su work
pm2 restart verdaccio 重启服务生效
刷新页面吧亲。不知道为什么,仅写theme: ****或者换行不生效,反正我也不懂,能用就行
添加用户
去网站生成密码,然后将密码添加到服务端密码文件中,记得重启服务
默认配置
#
# 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/verdaccio/verdaccio/tree/master/conf
# # path to a directory with all packages
storage: ./storage
# path to a directory with plugins to include
plugins: ./plugins web:
title: Qianjunet npm repo
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc 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: -1 # a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/ packages:
'@*/*':
# scoped packages
# access: $all
access: $authenticated
publish: $authenticated
unpublish: $authenticated
proxy: npmjs '**':
# 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
access: $authenticated # allow all known users to publish/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated # if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs # You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
keepAliveTimeout: 60 middlewares:
audit:
enabled: true # log settings
logs:
#- { type: stdout, format: pretty, level: http }
- {type: file, path: ./verdaccio.log, level: info}
#experiments:
# # support for npm token command
# token: false
配置nginx, 将请求转发到4873服务
server {
listen 80;
server_name npm.**********.com;
location / {
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:4873$request_uri;
proxy_redirect off;
}
}
如何使用?nrm
npm i -g nrm
查看当前所有npm的镜像源
nrm ls
使用淘宝源
1
nrm use taobao
添加我们自定义的私有仓库的源
1
nrm add ******** http://npm.*****.com
使用自定义的源
1
nrm use ********
添加错误后,可删除源
1
nrm del *****
切换到自定义npm源后,使用npm登录
1
2
3
4
5
6nrm use ******
npm login
input username:
input password:
input public email:
输入相关信息后登录成功,登录成功即可使用npm install some-package-name
发布package
1 |
npm init |
最终详细配置,还是得看官网,虽然官网的描述很不好懂,而且不全,但是比本篇记录要全,毕竟这个只是小哥哥看完文档,实际操作后的随笔而已
TODO: 待对接npm的用户信息到https://gitlab.*****.com
NPM 私有仓库的搭建的更多相关文章
- ndoe.js 和npm私有仓库的搭建
下载nodejs的压缩包 网址:https://nodejs.org/en/ 下载以tar.xz结尾的包例如:node-v8.9.4-linux-x64.tar.xz 上传包到制定的目录 可以用lrz ...
- 使用verdaccio 搭建npm私有仓库
使用verdaccio 搭建npm私有仓库 1. 为什么要搭建私有的npm仓库? 随着公司的业务越来越复杂,项目迭代速度也越来越快,那么项目间的常用的业务代码共享变得非常之有必要.但是对于公司的 ...
- docker学习------docker私有仓库的搭建
192.168.138.102:23451.私有仓库的搭建(docker pull registry),拉取最新的镜像 2.查看拉取的仓库镜像(docker images) 3.启用registry镜 ...
- docker 私有仓库简易搭建
概要 本地私有仓库 局域网私有仓库 总结 概要 docker hub 使用非常方便,而且上面有大量的镜像可以使用. 但是,每次都远程下载镜像速度非常慢,如果能在本地做一个 docker 的仓库,多人协 ...
- Git 安装及用法 github 代码发布 gitlab私有仓库的搭建
版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统. 这个版本控制软件,有 svn还有git,是一个工具. git是由linux的作者开发的 git是一个分布式版本控制系统 ...
- 使用verdaccio+docker搭建npm私有仓库以及使用
公司内部前端组件或库的共享等,搭建一个npm私有库就很方便,现在中大型公司也基本都有自己的npm私有库,这篇文章,和大家一起共同搭建一个npm私有库,共同学习 前置条件 一台电脑 可以联网 一.安装d ...
- npm私有仓库 配置verdaccio在docker环境
前端开发过程中,少不了自己封装一些通用的包,但又不想放在公共的平台,所以搭建一个npm私有的仓库是很有必要的. 在这里简单介绍如何使用 verdoccio 在docker环境下的配置.verdocci ...
- Docker私有仓库Registry 搭建
1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候,我们的使用场景需要我们拥有一个私有 ...
- 基于IP的docker private registry 私有仓库的搭建
鉴于国内的网络环境,如果公司内部大量使用docker,镜像上传下载将是个非常耗时的工作,搭建一个私有仓库可以很好的解决自有镜像的存储,如果你在私有网络,不能使用域名的话,那么本文可以作为一个很好的例子 ...
随机推荐
- A 【NOIP2012 day2】疫情控制
时间限制 : 20000 MS 空间限制 : 128000 KB 评测说明 : 2s,128m 问题描述 H 国有 n 个城市,这 n 个城市用 n-1 条双向道路相互连通构成一棵树,1 号城市是 ...
- B【SDOI2008】Sandy的卡片
时间限制 : 5000 MS 空间限制 : 128000 KB 问题描述 Sandy和Sue的热衷于收集干脆面中的卡片.然而,Sue收集卡片是因为卡片上漂亮的人物形象,而Sandy则是为了积攒卡片 ...
- 在写微信小程序如何 首次编译的是当前写的页面
首先点击顶部的编译如下图 染后点击添加模式哈 选择页面加载是启动的是哪一个页面
- 【高并发】高并发环境下如何优化Tomcat配置?看完我懂了!
写在前面 Tomcat作为最常用的Java Web服务器,随着并发量越来越高,Tomcat的性能会急剧下降,那有没有什么方法来优化Tomcat在高并发环境下的性能呢? Tomcat运行模式 Tomca ...
- std::string构造函数
string(); string (const string& str); string (const string& str, size_t pos, size_t len = np ...
- AJ学IOS(30)UI之Quartz2D画图片画文字
回头看了看自己写的博客,AJ决定以后更改风格 本意是想大家看效果直接拷贝代码能用,注释齐全也方便学习,但是发现这样对新手学习特别困难 以后风格基本是–>看标题–>看目录–>看图片–& ...
- 在学习java之余,js的使用精髓-闭包和原型链
这里分享下廖雪峰官网写的js教程,内容写的比较实用,易懂,其中简介的原型链和闭包的知识,小伙伴们一起上呀,畅游在知识的海洋中: 地址:https://www.liaoxuefeng.com/wiki/ ...
- Daily Scrum 12/23/2015
Process: Zhaoyang: Compile the Caffe IOS version and make it run in the IOS9. Yandong: Finish the Az ...
- J - Recommendations CodeForces - 1315D
https://blog.csdn.net/w_udixixi/article/details/104479288 大意:n个数,每个数只能向上加,a[i]+1需要的时间是t[i],求使这n个数无重复 ...
- N - Aroma's Search CodeForces - 1293D math+greedy
作为DIV2的D题来讲,这个题目不算难. 题目大意:再规定的时间内寻找宝藏,第i个宝藏的位置为a*x(i-1)+b,a*y(i-1)+b.然后给出初始位置xs,ys和时间t让求再时间t内能够寻找到多少 ...