参考
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
创建账号
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
刷新页面,即可查看发布信息
下载私服包
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