检查环境 node -v npm -v 如果没有弄得环境请先安装nodejs
检查防火墙
查看防火墙规则:firewall-cmd --list-all
查询端口是否开放firewall-cmd --query-port=4873/tcp(默认端口,可以自定义)
开放4873端口firewall-cmd --permanent --add-port=4873/tcp (默认端口,可以自定义)
阿里云服务器请开放安全组端口
正式开始安装
npm install -global verdaccio --unsafe-perm(如果单纯-global报错使用当前命令)
#--unsafe-perm 说明:npm会有生命周期,某个包会有生命周期来执行一些东西,安全起见会自动降级导致没有权限执行一些操作,通过--unsafe-perm参数来解锁该限制。
运行 执行 verdaccio
记住第一行的配置信息很有用
当前服务是已经启动了,想要整个项目部署团队使用还要一些配置,下面让我们进入配置文件
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#
# path to a directory with all packages
# 所有包的缓存目录
storage: /Users/fodelf/.local/share/verdaccio/storage
# path to a directory with plugins to include
# 插件目录
plugins: ./plugins //
# web服务配置
web:
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
#验证服务
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
# a list of other known repositories we can talk to
#上游配置本地没有的资源去上游拉取,可以配置淘宝镜像,由于镜像本身问题建议使用源
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all
# allow all known users to publish/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
# log settings
logs:
- { type: stdout, format: pretty, level: http }
#- {type: file, path: verdaccio.log, level: info}
#experiments:
# # support for npm token command
# token: false
# 监听的端口 ,重点, 不配置这个,只能本机能访问
listen: 0.0.0.0:4873
修改配置文件之后,先 ctr + c 暂停verdaccio 任务 采用下面的方式重新启动
pm2进程守护(开发过node项目的同学知道,node进程跑几天就挂是常有的事情所以需要进程守护)
npm install -g pm2 --unsafe-perm
查找verdaccio可执行js的目录
whereis verdaccio
cd xx 进入目录
pm2 start verdaccio.js
整个服务端流程结束
启动号服务后,客户端访问地址 http://xxx:4873
客户端根据提示在终端执行以下命令
npm set xxx:4873
npm adduser xxx:4873
进入需要发布的插件目录下面
npm login
输入用户名,密码,邮箱
npm publish
发布插件
在客户端访问地址查看 插件是否上传成功
在项目中使用
npm i xx 插件名称
完结撒花!!!!!!!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有