Google Artifact Registry:删除包后仍无法发布相同版本的包

Google Artifact Registry: Unable to publish package with the same version even after package deletion

我正在尝试将 npm 包发布到 google 工件注册表 (GAR)。

已经发布了一个相同版本的包,但我已经从 GAR 中手动删除了它。

npm view <package-name>@0.1.3

<empty response>

但是还是无法发布包。

npm publish

npm ERR! code E400
npm ERR! 400 Bad Request - PUT https://<package-url> - Requested version(0.1.3) already exists.

看起来它已缓存在某处。如果是这样,是否有可能清除缓存?

根据 this documentation:

,实际上 Cloud Artifacts Registry 不允许这样做

You can only publish a specific version of a package once. This is an npm restriction to ensure that the contents of a published package version are always the same. As a result, you cannot:

  • Overwrite a package version by publishing it again to the repository
  • Remove a package or its version from the repository, and then publish a package with the same name and version number

因此您必须创建另一个版本才能发布包。

警告:这不是针对包含相当多软件包及其版本的现有存储库的解决方案!

还有一种方法可以做到这一点,但它需要删除并重新创建整个存储库。 所以:

  1. 删除整个存储库
  2. 使用相同的名称和选项重新创建存储库。