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.
- Make backup of the of the files in package storage. When deleting, it will be move to the<npm-hosted-repo-id>/.nexus/trash directory, but always worth having an extra backup.
- 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>
- 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>/
- Remove the version you do not want to keep.
- Rebuild the npm database for repository <npm-hosted-repo-id> with the scheduled task named "Rebuild hosted npm Metadata".
- The following URL should now have correct metadata without version that was deleted
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.