当您尝试发布到代理打包时,verdaccio 如何工作?

How does verdaccio work when you try to publish to a proxied packaged?

文档中并不清楚什么是 Verdaccio 代理。

如果我为 @acme/foo 设置了代理,而有人以 Verdaccio 为目标试图发布 @acme/foo,我该如何配置该行为以及默认设置是什么?存在三种明显的可能性,但文档中涵盖了其中的 none,

  1. 发布被拒绝
  2. 发布已被代理。
  3. 发布在本地完成,进一步的请求不会被代理。

我更喜欢第三个选项,但是当我尝试发布到一个被代理的包时,我在 npm 中得到了这个,

npm ERR! code EPUBLISHCONFLICT
npm ERR! publish fail Cannot publish over existing version.
npm ERR! publish fail Update the 'version' field in package.json and try again.
npm ERR! publish fail 
npm ERR! publish fail To automatically increment version numbers, see:
npm ERR! publish fail     npm help version

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ecarroll/.npm/_logs/2021-11-11T18_45_39_813Z-debug.log

发布发生在本地,但仅在本地 Verdaccio 服务器连接到远程服务器并验证没有冲突版本之后。

When you are trying to publish a package@version and you have uplinks defined (by default is npmjs) it will:

  1. Ask to the defined uplink (in case you have the proxy: npmjs in your package access`) and download the manifest if exist, if does not will just don't persist anything (jump to step 3)
  2. Will verify if in that manifest (in case step 1 is positive) if the version already exist.
  3. If exist, will return 409 http status (http conflict) <-- what npmjs will display is EPUBLISHCONFLICT if not, will publish the package. Here more info: https://verdaccio.org/docs/best#override-public-packages

In a nutshell, if the package access section has proxy it will always double check with the uplink and won't allow you have duplications.

这取自Juan Picado on GitHub from a discussion that I opened up