檢查環境 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 插件名稱複製代碼
完結撒花!!!!!!!