6

i was use Verdaccio which is a lightweight private npm proxy registry built in Node.js

when i publish my code to verdaccio ,it always have a Error:

enter image description here

the logs file key word: 15 notice === Tarball Details === 16 notice name: canwin-viewer3d 16 notice version: 1.0.0 16 notice package size: 21.9 MB 16 notice unpacked size: 50.4 MB 16 notice shasum: 63d555be03e0c7a7b6dcdfb662d29c48b21d8c53 16 notice integrity: sha512-KFz0gTPJusdfV[...]VIeII6rrcv4IA== 16 notice total files: 733 17 notice 18 http fetch PUT 413 http://localhost:4873/canwin-viewer3d 677ms 19 verbose stack Error: 413 Payload Too Large - PUT http://localhost:4873/canwin-viewer3d - request entity too large 19 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15 19 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5) 20 verbose statusCode 413 21 verbose pkgid canwin-viewer3d@1.0.0 22 verbose cwd C:\work\viewer3d 23 verbose Windows_NT 10.0.18363 24 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "publish" 25 verbose node v13.10.1 26 verbose npm v6.13.7 27 error code E413

it seems that the PUT Quest PayLoad was Large ,so i try to find the verdaccio config file,but i have nothing ,verdaccio it code maybe use node express to run ,how can i setting the Put Payload size?

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
ioy
  • 61
  • 1
  • 2

1 Answers1

6

So generally you can face two problems with 413 errors.

  • Verdaccio default body size is 1 MB so you have to increase that on the client side:

npm config set max_body_size 100mb --registry https://<your registry>

  • If this does not work then you may need to increase it on the server side as the doc suggest. Add to the configuration file the following line.

values.yaml

...

  max_body_size: 100mb

....
  • If this still does not work then most likely you have a problem with your proxy.

If this is a nginx proxy you can try:

http {
    ...
    client_max_body_size 100M;
} 

or if this is a node.js server you can use the bodyParser as described in detail in this thread:

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
Ivasan
  • 101
  • 1
  • 7
  • can you tell me please how can I increase max_body in the server side? I don't have this file on my machine values.yaml, nginx.conf – jocoders Dec 30 '21 at 10:23
  • 1
    Can you maybe explain how did you install verdaccio? well, in the case if you are using kubernetes, I recommend deploying verdaccio via its [helm repository](https://github.com/verdaccio/charts/tree/master/charts/verdaccio). Then you can set the value `max_body_size` in the [values.yaml](https://github.com/verdaccio/charts/blob/master/charts/verdaccio/values.yaml) file. You only need the `nginx` proxy if you are routing your traffic via an `nginx` server.(base d on your comment you do not) – Ivasan Jan 03 '22 at 12:50
  • Hello! But if I did not installed Verdaccio. For publish npm package you did not need to install it. But what to do if this command is not working? And I did not install any proxy for Verdaccio, it does not need too for publish package. – jocoders Jan 11 '22 at 11:38
  • 1
    Well, you could add this to your npmrc config file. Usually it is located in `${HOME}/.npmrc`: `max_body_size: 200mb=true` Have you tried that? Other than that if you don't use Verdaccio, but the official NPM website, you can look around your repo seetings there. What seems to be your issue? – Ivasan Jan 12 '22 at 12:59
  • I tried to change .npmrc file, but it is not working. Get the error after npm publish: 413 Request Entity Too Large. My package about 163mb – jocoders Jan 12 '22 at 13:16
  • 1
    Are you trying to publish to npmjs or privately hosted repo? – Ivasan Jan 13 '22 at 14:10
  • Its a private repo in Verdaccio – jocoders Jan 20 '22 at 06:16
  • 1
    Setting max_body_size via `npm config` didn't fix the issue for me, but setting max_body_size in Verdaccio's config did, as per the docs: https://verdaccio.org/docs/configuration/#max-body-size. – Caleb Koch Feb 01 '22 at 17:36
  • I just increased the limit on my Verdaccio server (running in a Docker container on my Synology NAS) by adding `max_body_size: 100mb` to the `config.yaml` file. I'm not aware of any `values.yaml` file, but changing the `config.yaml` does work. Also, I used `100mb` instead of `100M`, since that's the format the Verdaccio docs use. https://verdaccio.org/docs/configuration/#max-body-size – Michael Ryan May 31 '22 at 01:17