使用Sinopia部署私有npm仓库
2024-09-01 19:19:36
使用Sinopia部署私有npm仓库
[root@localhost ~]# hostnamectl set-hostname --static npm-server
[root@npm-server ~]# curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash
[root@npm-server ~]# yum install -y nodejs # 先要有nodejs
[root@npm-server ~]# node -v # 查看nodejs的版本
v10.21.0
[root@npm-server ~]# npm -v
6.14.4
# 将node源改为淘宝源,有两种方式查看是否修改成功
[root@npm-server ~]# npm config set registry https://registry.npm.taobao.org # 永久修改
[root@npm-server ~]# npm info express
express@4.17.1 | MIT | deps: 30 | versions: 264
Fast, unopinionated, minimalist web framework
http://expressjs.com/
dist
.tarball: https://registry.npm.taobao.org/express/download/express-4.17.1.tgz
.shasum: 4491fc38605cf51f8629d39c2b5d026f98a4c134
dependencies:
accepts: ~1.3.7 depd: ~1.1.2 on-finished: ~2.3.0
array-flatten: 1.1.1 encodeurl: ~1.0.2 parseurl: ~1.3.3
body-parser: 1.19.0 escape-html: ~1.0.3 path-to-regexp: 0.1.7
content-disposition: 0.5.3 etag: ~1.8.1 proxy-addr: ~2.0.5
content-type: ~1.0.4 finalhandler: ~1.1.2 qs: 6.7.0
cookie-signature: 1.0.6 fresh: 0.5.2 range-parser: ~1.2.1
cookie: 0.4.0 merge-descriptors: 1.0.1 safe-buffer: 5.1.2
debug: 2.6.9 methods: ~1.1.2 send: 0.17.1
(...and 6 more.)
maintainers:
- jasnell <jasnell@gmail.com>
- mikeal <mikeal.rogers@gmail.com>
dist-tags:
latest: 4.17.1 next: 5.0.0-alpha.8
published a year ago by dougwilson <doug@somethingdoug.com>
[root@npm-server ~]# npm config get registry
https://registry.npm.taobao.org/
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# 如果想还原npm仓库地址的话,只需要在把地址配置成npm镜像就可以了
[root@npm-server ~]# npm config set registry https://registry.npmjs.org/
# 安装sinopia
[root@npm-server ~]# npm install -g sinopia # -g表示全局安装,没有-g需要在当前目录下安装
[root@npm-server ~]# sinopia # 看到下面两行,表示启动成功了
Sinopia doesn't need superuser privileges. Don't run it under root.
warn --- config file - /root/.config/sinopia/config.yaml
warn --- http address - http://localhost:4873/
[root@npm-server ~]# cd .config/sinopia/
[root@npm-server sinopia]# ls
config.yaml storage
[root@npm-server sinopia]# cp config.yaml{,.bak}
[root@npm-server sinopia]# vim 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: ./storage # npm包存放的路径
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 # 默认为1000,改为-1,禁止注册
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: http://registry.npm.taobao.org/ # 默认为npm的官网,由于国情,修改 url 让sinopia使用 淘宝的npm镜像地址
packages: # 配置权限管理
'@*/*':
# scoped packages
access: $all # 表示哪一类用户可以对匹配的项目进行安装 【$all 表示所有人都可以执行对应的操作,$authenticated 表示只有通过验证的人可以执行对应操作,$anonymous 表示只有匿名者可以进行对应操作(通常无用)】
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 # 如其名,这里的值是对应于 uplinks
# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: sinopia.log, level: info}
# you can specify listen address (or simply a port)
listen: 0.0.0.0:4873 # 默认没有,只能在本机访问,添加后可以通过外网访问
最新文章
- ORACLE 11G EXPDP交互模式 interactive mode
- 海量日志分析方案--logstash+kibnana+kafka
- HTML 30分钟入门教程
- .net串口通信
- 用过sessionid防钓鱼
- 通过CSS禁止Chrome自动为输入框添加橘黄色边框,修改/禁止 chrome input边框颜色,
- 面试题总结之JAVA
- 平稳退化,JS和HTML标记分离,极致性能的JavaScript图片库
- 转换GridView的内容到Excel里面 ---带有格式
- python修炼7----迭代器
- 【一通百通】Bash的单双括号建议:多用[[]], 少用[]
- Linux 安装qt5-designer并集成到Pycharm
- 腾讯笔试编程题,贪吃的小Q(二分查找)
- Consul之:服务注册与发现
- JmsTemplate sendAndReceive 设置超时
- String,InputStream相互转换
- linux 使用文件作为交换分区
- Java高并发syncronized深入理解
- Spring4 MVC RESTFul WebServices CRUD实例+RestTemplate
- Spark实施备忘
热门文章
- 灵雀云入选Gartner 2020中国ICT技术成熟度曲线报告,容器技术处于顶峰
- 阿里神器 Seata 实现 TCC模式 解决分布式事务,真香!
- Nginx高级模块学习
- 利用Spring AOP切面对用户访问进行监控
- 【涨姿势】原来golang的case <;-time.After(xxx)还有这样的坑
- linux下编译支持opencl的opencv for android
- 集合框架-TreeSet-Comparator比较器练习(字符串长度排序)
- log4j学习记录以及相关配置(精简版)
- db2服务器linux的cache过高原因
- CPU飙升排查