Verdaccio
1、docker-compose
version: "3.1"
services:
verdaccio:
image: verdaccio/verdaccio:5.0
container_name: "verdaccio"
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
ports:
- "4873:4873"
volumes:
- "~/WorkSpace/Docker/Verdaccio/storage:/verdaccio/storage"
- "~/WorkSpace/Docker/Verdaccio/config:/verdaccio/conf"
- "~/WorkSpace/Docker/Verdaccio/plugins:/verdaccio/plugins"
networks:
node-network:
driver: bridge
web:
title: "npm私服"
storage: /verdaccio/storage
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
uplinks:
npmjs:
url: https://registry.npm.taobao.org/
packages:
"@company/*":
access: $authenticated
publish: $authenticated
unpublish: $authenticated
"@*/*":
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
"**":
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
logs:
- { type: stdout, format: pretty, level: http }
docker-compose up -d
2、使用私服 npm
2-1、添加用户
npm adduser --registry http://localhost:4873
npm login --registry http://localhost:4873
2-1、全局使用
npm set registry=http://localhost:4873/
yarn config set registry http://localhost:4873/
# 全局使用后,则不用每个命令后都加 --registry http://localhost:4873
2-2、按需使用
npm install --registry http://localhost:4873
npm publish --registry http://localhost:4873
3、使用记录
3-1、未登录则无法安装
3-2、未登录则无法发包
3-3、待解决问题
1、总是匿名的问题。
2、如何禁止用户注册,换为管理员分配账号。