verdaccio发布私有库

2020-08-04  本文已影响0人  栗子daisy

Ver‘dac’cio是一个当前非常流行的NPM私有Package仓库的开源项目。
官网https://github.com/verdaccio/verdaccio

操作 指令 提示
安装verdaccio npm install -g verdaccio
启动verdaccio verdaccio Verdaccio started
安装nrm工具 npm install -g nrm
添加私有源 nrm add dnpm http://localhost:4873 add registry dnpm success
使用私有源 nrm use dnpm Registry has been set to: http://localhost:4873/
测试私有源速度 nrm test dnpm * dnpm --- 51ms
未注册先注册
npm adduser --registry http://localhost:4873/
密码要10个字符
Logged in as dai**li on http://localhost:4873/
注册过登录 npm login Logged in as dai**li on http://localhost:4873/
发布私有库 npm publish + dip@1.1.5

1.安装verdaccio

npm install --global verdaccio

verdaccio

 warn --- config file  - C:\Users\li*****\.config\verdaccio\config.yaml
 warn --- Verdaccio started
 warn --- Plugin successfully loaded: verdaccio-htpasswd
 warn --- Plugin successfully loaded: verdaccio-audit
 warn --- http address - http://localhost:4873/ - verdaccio/4.8.0

为了切换源方便,可以使用nrm

npm install -g nrm

nrm ls

* npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/
dnpm ------- http://localhost:4873/

nrm add 私有源名称 http://verdaccio托管的ip地址:4873

nrm add dnpm http://localhost:4873
add registry dnpm success

切换源

$ nrm use 自定义私有库名称
Registry has been set to: http://verdaccio托管的ip地址:4873

nrm use dnpm
nrm use npm
发布npm包之前必须先注册账号
1、注册
npm adduser --registry http://XX.XXX.XXX.XXX:4873/
输入npm账号用户名、密码和邮箱,即可创建一个账户。如下:

Username: dais**li
Password:cY***1***
Email: (this IS public) 11*****28@qq.com
Logged in as dais**li on http://localhost:4873/.

输出Logged in as **** on http://XX.XXX.XXX.XXX:4873/,表示npm账号kengsir成功登录到http://XX.XXX.XXX.XXX:4873/私有仓库了。

1、如果有注册过则登录, 密码需要超过10个字符

npm login

Username: dais**li
Password:cY***1***
Email: (this IS public) 11*****28@qq.com

5.发布私有库

npm publish --registry http://verdaccio托管的ip地址:4873

npm publish --registry http://localhost:4873

6.安装私有库
npm i 私有库名称

7.使用私有库

var 私有库名称 = require('私有库名称');
https://catchzeng.com/2018/05/22/%E5%9B%A2%E9%98%9F%E9%9C%80%E8%A6%81%E4%B8%80%E4%B8%AA%E7%A7%81%E6%9C%89npm/

verdaccio 离线环境下包发布

亲测:可以离线发布,如果报错

需要在config.yaml中增加以下条目,重启verdaccio即可在离线环境下发布包。

#####################################################################
# Advanced settings
#####################################################################

## Special packages publish configurations
publish:
## This will allow the publisher to publish packages even if any uplink is down.
  allow_offline: true

tar包路径

C:\Users\liy*******.config\verdaccio\storage\dip


nrm home dnpm

好文推荐
npm私服搭建—verdaccio方案及其最佳实践

上一篇下一篇

猜你喜欢

热点阅读