检查环境 node -v npm -v 若是没有弄得环境请先安装nodejsnode
检查防火墙git
查看防火墙规则:firewall-cmd --list-all
查询端口是否开放firewall-cmd --query-port=4873/tcp(默认端口,能够自定义)
开放4873端口firewall-cmd --permanent --add-port=4873/tcp (默认端口,能够自定义)
阿里云服务器请开放安全组端口复制代码
正式开始安装github
npm install -global verdaccio --unsafe-perm(若是单纯-global报错使用当前命令)
#--unsafe-perm 说明:npm会有生命周期,某个包会有生命周期来执行一些东西,安全起见会自动降级致使没有权限执行一些操做,经过--unsafe-perm参数来解锁该限制。复制代码
运行 执行 verdaccioweb
记住第一行的配置信息颇有用npm
当前服务是已经启动了,想要整个项目部署团队使用还要一些配置,下面让咱们进入配置文件缓存
#
# 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进程跑几天就挂是常有的事情因此须要进程守护)bash
npm install -g pm2 --unsafe-perm
查找verdaccio可执行js的目录
whereis verdaccio
cd xx 进入目录
pm2 start verdaccio.js复制代码
整个服务端流程结束服务器
启动号服务后,客户端访问地址 http://xxx:4873tcp
客户端根据提示在终端执行如下命令
npm set xxx:4873
npm adduser xxx:4873
进入须要发布的插件目录下面
npm login
输入用户名,密码,邮箱
npm publish
发布插件复制代码
在客户端访问地址查看 插件是否上传成功
在项目中使用
npm i xx 插件名称复制代码
完结撒花!!!!!!!