How to delete an npm package from the npm registry

2020-02-08 05:45发布

问题:

Is there a possible way to remove or delete the entire module from npm registry?

Notice: npm -f unpublish doesn't allowed you to unpublish anything older than 24 hours

回答1:

There's a post about that, given the recent incident. Your best bet would be to contact npm and hope that your package isn't depended by other projects.

If the version is older than 24 hours, then the unpublish will fail, with a message to contact support@npmjs.com.

If you contact support, they will check to see if removing that version of your package would break any other installs. If so, we will not remove it. You’ll either have to transfer ownership of the package or reach out to the owners of dependent packages to change their dependency.

http://blog.npmjs.org/post/141905368000/changes-to-npms-unpublish-policy



回答2:

TL;DR:

npx force-unpublish package-name 'reason message'

Explanation:

  1. npm deprecate package-name 'reason message'
  2. npm owner add npm package-name
  3. npm owner rm $(npm whoami) package-name

https://www.npmjs.com/package/force-unpublish



回答3:

From the docs: https://www.npmjs.com/policies/unpublish

npm deprecate <package> "<message>" to deprecate the entire package
npm deprecate <package>@<version> "<message>" to deprecate a specific version
If the entire package is deprecated, the package name will be dropped from our search results.

Once deprecated, if you would also like for the package to be removed from your user profile,
it can be transferred to our @npm account. This can be achieved by using the following from your command line:

npm owner add npm <package>
npm owner rm <your_username> <package>