简体   繁体   中英

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

I'm trying to publish npm package to the google artifact registry (GAR).

A package with the same version has already been published, but I've deleted it manually from the GAR.

npm view <package-name>@0.1.3

<empty response>

But still unable to publish the package.

npm publish

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

Looks like it has been cached somewhere. If so is there any possibility to clear the cache?

Actually Cloud Artifacts Registry does not allow that, according to this documentation :

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

So you are going to have to create another version in order to publish the package.

Warning : this is NOT a solution for existing repositories that contain quite some packages and their versions!

There's still a way to do this, BUT it requires deleting and recreating the whole repository. So:

  1. Delete the whole repository
  2. Recreate the repository with the same name and options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM