私有NPM仓库部署
2024-08-19
- 首先不建议自己搭建npm仓库,即使是企业,建议使用npm官方的npm仓库,因为自己npm仓库非常麻烦。
- 真的有私有NPM仓库的需求,建议使用三方Devops工具中的制品仓库,稳定性更高,权限管理也很细致。
一、开源项目 Verdaccio
二、Docker部署
参考:http://www.hzhcontrols.com/new-36364.html
1、安装docker和docker-compose
2、编写配置
- 建立目录结构
- docker-compose配置docker-compose.yaml文件
yaml
version: '1.0'
services:
verdaccio:
image: verdaccio/verdaccio
container_name: verdaccio
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
ports:
- 4873:4873
volumes:
- ./storage:/verdaccio/storage
- ./config:/verdaccio/conf
- ./plugins:/verdaccio/plugins
- ./logs:/verdaccio/logs
networks:
node-network:
driver: bridge
- 编写verdaccio的配置文件
yaml
storage: /verdaccio/storage
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
uplinks:
npmjs:
url: https://registry.npm.taobao.org/
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
'**':
access: $authenticated
publish: $authenticated
proxy: npmjs
logs:
- {type: stdout, format: pretty, level: http}
3、启动docker
shell
docker-compose up -d --build
三、使用
- Login
shell
npm adduser --registry https://npmjs.iwxh5.cn/
- Publish
shell
npm publish --registry https://npmjs.iwxh5.cn/
- Refresh this page.