Deleting a specific npm package version in Nexus Repository Manager 2.x

The official npm tool maintainers viewpoint is that deleting npm packages from a registry is not a recommended operation. The npm deprecate command is preferred, however only Nexus Repository Manager 3.x supports the deprecate command.

We realize there may be occasional need to delete an npm package in Nexus 2 and this article outlines a workaround for the missing deprecate support in that version.

Removing A Specific npm Package Version

Instructions for deleting a specific npm package version in all 2.x repository manager versions starting at version 2.11.3. Earlier versions are not supported.

  1. Make backup of the of the files in package storage. When deleting, it will be moved to the<npm-hosted-repo-id>/.nexus/trash directory, but always worth having an extra backup.

    sonatype-work/nexus/storage/<npm-hosted-repo-id>/<package-name>

  2. Delete the npm package (this will delete all versions of that package) using the following call:

    curl -X DELETE -u xxx:yyy http://nexus:8081/nexus/content/repositories/<npm-hosted-repo-id>/<package-name>

  3. Copy/Move back the package from trash 

    cp -r sonatype-work/nexus/storage/<npm-hosted-repo-id>/.nexus/trash/<package-name> sonatype-work/nexus/storage/<npm-hosted-repo-id>/

  4. Remove the version you do not want to keep. 

    rm sonatype-work/nexus/storage/<npm-hosted-repo-id>/<npm-hosted-repo-id>/-/<npm-hosted-repo-id>-<version>.tgz

  5. Rebuild the npm database for repository <npm-hosted-repo-id> with the scheduled task named "Rebuild hosted npm Metadata".

  6. The following URL should now have correct metadata without version that was deleted

    http://nexus:8081/nexus/content/repositories/<npm-hosted-repo-id>/<package-name>

Removing All Versions of an npm Package

From Repository Manager 2.11.3 onwards, you can now remove all versions of a specific npm package with a single command. See NEXUS-8062 for more details.

 



 

Have more questions? Submit a request

0 Comments

Article is closed for comments.