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,镜像上传下载将是个非常耗时的工作,搭建一个私有仓库可以很好的解决自有镜像的存储,如果你在私有网络,不能使用域名的话,那么本文可以作为一个很好的例子 ...
随机推荐
- 从春节送祝福谈谈 IO 模型(二)
上期结合程序员小猿用温奶器给孩子热奶的故事,把面试中常聊的“同步.异步与阻塞.非阻塞有啥区别”简单进行普及. 不过,恰逢春节即将到来,应个景,不妨就通过实现新春送祝福的需求,深入了解一下 Java I ...
- centos8系统下docker安装jenkins
前提是已经安装好docker 1.下载jenkins(最新版本) docker pull jenkins/jenkins 2.创建用于存放jenkins的文件夹 mkdir /home/var/jen ...
- Pytest系列(11)- 失败重跑插件pytest-rerunfailures详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 环境前提 以下先决条件才能使用py ...
- For,while,case,shell循环结构
For,while,case,shell循环结构 案例1:使用for循环结构 案 ...
- docker win10 推送镜像问题
镜像制作 docker build -t gameniuniu:v1.1 . 一.推送 1.docker images 中查找IMAGE ID镜像 2.docker commit <IMAGE ...
- linux中忘记了mysql的root用户的密码怎么办?
1.vim /etc/my.cnf skip-grant-tables #取消此行的注释 2.重启mysql systemctl restart mysqld 3.mysql 登陆mysql mys ...
- 如何在云开发静态托管中使用Jekyll
如何在云开发静态托管中使用Jekyll 介绍 Jekyll 是一个简单的博客形态的静态站点生产机器,通过它,我们可以搭建一个完整的可发布的静态博客网站. Jekyll 也可以运行在 GitHub Pa ...
- 中阶 d06.1 cookie && session && jsp介绍
##Cookie > 饼干. 其实是一份小数据, 是服务器给客户端,并且存储在客户端上的一份小数据 ### 应用场景 > 自动登录.浏览记录.购物车. ###为什么要有这个Cookie & ...
- matplotlib BlendedGenericTransform(混合变换)和CompositeGenericTransform(复合变换)
2020-04-10 23:31:13 -- Edit by yangrayBlendedGenericTransform是Transform的子类,支持在x / y方向上使用不同的变换.(博主翻译为 ...
- go 中的WaitGroup
wait_group sync.WaitGroup 类型是并发安全的,也是开箱就能用的. 该类型有三个指针方法,即:Add,Done和Wait. sync.WaitGroup是一个结构体类型.其中一个 ...