verdaccio 私有npm仓库

docker-compose / portainer

version: '3.7'

services:
  verdaccio:
    image: verdaccio/verdaccio
    container_name: "verdaccio"
    networks:
      - node-network
    environment:
      - VERDACCIO_PORT=5000
    ports:
      - "5000:5000"
    volumes:
      - "./storage:/verdaccio/storage/"
      - "./config:/verdaccio/conf/"
      - "./plugins:/verdaccio/plugins/"
    restart: always 
networks:
  node-network:
    driver: bridge

config

config/config.yaml

storage: /verdaccio/storage
auth:
  htpasswd:
    file: /verdaccio/conf/htpasswd
    max_users: 1000
uplinks:
  npmjs:
    url: https://registry.npmmirror.com/
packages:
  "@*/*":
    access: $all
    publish: $authenticated
    proxy: npmjs
  "**":
    access: $all
    publish: $authenticated
    proxy: npmjs
log: { type: stdout, format: pretty, level: http }
max_body_size: 1024mb
web:
  enable: true
  title: npm私有仓库
i18n:
  web: zh-CN

创建认证存储文件

/config/htpasswd

touch /config/htpasswd

配置目录文件权限

chown -R 10001 config/ plugins/ storage/

chgrp -R 10001 config/ plugins/ storage/

用户注册

npm adduser --registry http://ip:5000

显示公共包

修改 storage/.verdaccio-db.json
把需要显示的包名,添加到 list 变量的对象中