Verdaccio 搭建自己的仓储 -request entity too large

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
IIS 10.0 - 413.1 - Request Entity Too Large错误是指在使用IIS 10.0作为Web服务器时,当请求的实体(通常是请求的主体部分)超过服务器所允许的大小限制时,会出现该错误。这个错误通常发生在上传文件或提交大量数据的情况下。 解决这个问题的方法有以下几种: 1. 修改IIS配置文件:可以通过修改IIS的配置文件来增加请求实体的大小限制。打开IIS管理器,找到对应的网站或应用程序池,右键点击属性,选择"配置编辑器"。在"系统.webServer"节点下找到"security/requestFiltering/requestLimits"节点,将"maxAllowedContentLength"属性的值增加到所需的大小。保存更改后,重新启动IIS服务。 2. 修改Web.config文件:可以在网站的根目录下的Web.config文件中添加或修改以下配置来增加请求实体的大小限制: ```xml <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="xxx" /> </requestFiltering> </security> </system.webServer> ``` 其中,"xxx"表示所需的大小限制,以字节为单位。保存更改后,重新启动IIS服务。 3. 使用上传组件:如果您的应用程序需要处理大文件上传,可以考虑使用第三方的上传组件,如ASP.NET的FileUpload控件或者其他开源的上传组件。这些组件通常提供了更灵活的配置选项,可以轻松处理大文件上传。 4. 调整客户端请求:如果您无法修改服务器的配置或使用上传组件,您还可以尝试调整客户端请求的大小。例如,可以通过减小上传文件的大小或者分块上传的方式来避免超过服务器的限制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值