搭建 npm 私服


参考

Nodejs 第八章(npm搭建私服) - 掘金 (juejin.cn)

依赖安装

npm install verdaccio -g

PS Z:\npm> npm install verdaccio -g

added 264 packages in 2m

39 packages are looking for funding
  run `npm fund` for details

查看帮助

PS Z:\npm> verdaccio --help        
Launch the server

━━━ Usage ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

$ D:\node.js\node.exe D:\node_repo\global\node_modules\verdaccio\bin\verdaccio

━━━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  -l,--listen #0    host:port number to listen on (default: localhost:4873)
  -c,--config #0    use this configuration file (default: ./config.yaml)

━━━ Details ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This start the registry in the default port.

When used without arguments, it:

- bootstrap the server at the port  `4873`

The optional arguments are:

- `--listen` to switch the default server port,

- `--config` to define a different configuration path location,

━━━ Examples ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Runs the server with the default configuration
  $ verdaccio

Runs the server in the port 5000
  $ verdaccio --listen 5000

Runs the server by using a different absolute location of the configuration file
  $ verdaccio --config /home/user/verdaccio/config.yaml

启动服务

verdaccio

PS Z:\npm> verdaccio               
 info --- config file  - C:\Users\Administrator\AppData\Roaming\verdaccio\config.yaml
 info --- the "crypt" algorithm is deprecated consider switch to "bcrypt" in the configuration file. Read the documentation for additional details
 info --- using htpasswd file: C:\Users\Administrator\AppData\Roaming\verdaccio\htpasswd
 info --- plugin successfully loaded: verdaccio-htpasswd
 info --- plugin successfully loaded: verdaccio-audit
 warn --- http address - http://localhost:4873/ - verdaccio/5.29.2

image.png

创建账号

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

PS Z:\npm> npm adduser --registry http://localhost:4873/
npm notice Log in on http://localhost:4873/
Username: xyy123
Email: (this IS public) 2292600704@qq.com
Logged in on http://localhost:4873/.

登录账号

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

PS Z:\npm> npm login --registry http://localhost:4873/  
npm notice Log in on http://localhost:4873/
Username: xyy123
Password: Logged in on http://localhost:4873/.

发布npm包

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

PS Z:\npm> npm publish --registry http://localhost:4873/
npm notice 
npm notice 📦  mypackage@1.0.0
npm notice === Tarball Contents === 
npm notice 5B   index.html  
npm notice 20B  index.js    
npm notice 503B package.json
npm notice 19B  post.js     
npm notice 19B  prev.js     
npm notice === Tarball Details === 
npm notice name:          mypackage
npm notice version:       1.0.0
npm notice filename:      mypackage-1.0.0.tgz
npm notice package size:  460 B
npm notice unpacked size: 566 B
npm notice shasum:        43b346d1f441822248799fd3104bd06f232d9bf8
npm notice integrity:     sha512-A6gbjvm0UwKLc[...]h3qYHyKXo0bxw==
npm notice total files:   5
npm notice 
npm notice Publishing to http://localhost:4873/ with tag latest and default access

刷新页面,即可查看发布信息

image.png

下载私服包

npm install mypackage --registry http://localhost:4873/

PS Z:\npm> npm install mypackage --registry http://localhost:4873/

added 1 package, and audited 36 packages in 7s

4 packages are looking for funding
  run `npm fund` for details

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值