google-cloud-platformgoogle-cloud-artifact-repository

After deleting npm package i can still not upload a new one with same version


After running following command

gcloud artifacts versions delete 1.0.4 --package=XXX --repository=XXX --project=XXX --location=XXX --async

and also manualy deleting npm package i still get

Requested version(1.0.0) already exists.

When trying to upload my library.


Solution

  • As stated in the 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

    Also mentioned in the Documentation,

    After a package version is published, you cannot republish a package with the same name and version combination, even after deleting the version. This is an npm restriction to ensure that the contents of a published package version are always the same.

    This is to ensure reproducible builds, and it is considered best practice to publish a newer patch instead of the same version once a version is deleted, which Artifact Registry supports. It is recommended that publishing a minor version update instead.

    One more workaround is to create a new artifact registry and add all the intended packages to the new artifact registry to overcome the npm restriction mentioned above.