Verdaccio 搭建自己的仓储:
想试着打一个自己的仓储,来存放vue的组件,然后遇到了各式各样的坑,刚爬出来,赶紧记录一下
操作
基本按这篇文章来的:https://www.yuque.com/u548790/tech/xbwmls
和这篇https://zhuanlan.zhihu.com/p/134603457
先安装
npm i verdaccio -g
然后会发现安装到了:
C:\Users[username]\AppData\Roaming\npm\node_modules\verdaccio
接下来直接启动Verdaccio :
cmd直接输入命令:Verdaccio
回车
然后发现它跑起来了:
进入页面:http://localhost:4873/
能访问(这里是默认端口,没有改过)
接下来添加用户:
npm adduser --registry http://your_ip:4873
然后就迫不及待的发个包试试:
切换到包的根目录下
npm publish --registry http://your_ip:4873
结果尴尬了:
报错:error 413 Payload Too Large - PUT http://localhost:4873/edite-table - request entity too large
翻译一下就知道为什么报错了,我的文件夹39mb,肯定是太大了
然后去上网查,不难找到,加个配置项就可以了:
max_body_size: 10mb(这是默认值)
问题是配置文件在哪,网上说的
而 Verdaccio 的配置文件是在 ~/.config/Verdaccio 文件夹的 config.yaml
我严重怀疑这是Linux系统路径
我改了根目录下conf/default.yaml和docker.yaml文件,改了又改试了又试,然而没什么卵用
然后找到了官网
https://verdaccio.org/zh-CN/docs/configuration
也没看到window系统下的配置文件路径,
经过了解和分析后发现,应该对应的是这里:
C:\Users[username]\AppData\Roaming\verdaccio 的 config.yaml
#
# 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: ./storage
# path to a directory with plugins to include
plugins: ./plugins
web:
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# convert your UI to the dark side
# darkMode: true
# logo: http://somedomain/somelogo.png
# favicon: http://somedomain/favicon.ico | /path/favicon.ico
# rateLimit:
# windowMs: 1000
# max: 10000
# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
# web: en-US
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 }
max_body_size: 100mb
#experiments:
# # support for npm token command
# token: false
# # disable writing body size to logs, read more on ticket 1912
# bytesin_off: false
# # enable tarball URL redirect for hosting tarball with a different server, the tarball_url_redirect can be a template string
# tarball_url_redirect: 'https://mycdn.com/verdaccio/${packageName}/${filename}'
# # the tarball_url_redirect can be a function, takes packageName and filename and returns the url, when working with a js configuration file
# tarball_url_redirect(packageName, filename) {
# const signedUrl = // generate a signed url
# return signedUrl;
# }
# This affect the web and api (not developed yet)
# 改成中文
i18n:
web: zh-CN
在服务器部署的时候,发现启动的verdaccio关不掉,资源管理器中没有这个名字,用下面命令在cmd中按端口排查,终于发现了它叫node-_-||
netstat -ano