docker镜像拉取
# 使用docker搭建,略过下面这种使用方式
# npm install --global verdaccio
docker pull verdaccio/verdaccio
mkdir -p ~/docker/verdaccio
cd ~/docker/verdaccio
git clone https://github.com/verdaccio/docker-examples
cd ~/docker/verdaccio/docker-examples
mv docker-local-storage-volume ~/docker/verdaccio
rm -rf ~/docker/verdaccio/docker-examples
chown -R 10001:65533 ~/docker/verdaccio
编辑配置文件vim docker/verdaccio/conf/config.yaml
# path to a directory with all packages
storage: ../storage
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: 1000
uplinks:
npmjs:
#url: https://registry.npmjs.org/
url: https://registry.npm.taobao.org/
listen: 0.0.0.0:4873
启动镜像并配置npm
docker run --name verdaccio -itd -v ~/docker/verdaccio:/verdaccio -p 4873:4873 verdaccio/verdaccio
# 打开 http://localhost:4873 验证
npm set registry http://localhost:4873/
npm install -g nrm
nrm ls
nrm add verdaccio http://127.0.0.1:4873
# nrm del verdaccio
nrm use verdaccio
npm adduser --registry http://localhost:4873
npm publish --registry http://localhost:4873
npm unpublish <package-name> --force
npm unpublish --force [packageName@version]
测试发布
mkdir ~/test
cd ~/test
npm init -y
npm publish