Renaming a published NPM module

From the documentation:

Registry data is immutable, meaning once published, a package cannot change. We do this for reasons of security and stability of the users who depend on those packages.

However newly published packages - within 72 hours - can be unpublished by running:

npm unpublish <package_name> -f

This will remove the package from the NPM registry if it was published less than 72 hours ago. Then you can change your package's name and publish it again.

Caution: You need to wait 24 hours if you try to republish package with the same name


In less than 24 hours i ran following command to delete wrong package.

npm unpublish <wrong package name> --force

In simple words no you can't. But npm provides you a different solution called npm deprecate.

What it does is it marks a particular version or version ranges of that package as deprecated. So next if someone tries to install this package they get a warning package deprecated along with your custom message, in which you can easily specify your new package name.

Usage:

npm deprecate my-package-name@"< latest-version" "your message"

Your message can be any thing like:

WARNING: This project has been renamed to your-new-package-name. Install using new-package-name instead.

There isn't any exposed way to do that. When I've encountered this in the past the approach I took was:

npm deprecate %ProjectName%@"<=put-latest-version-here" "WARNING: This project has been renamed to %NewProjectName%. Install using %NewProjectName% instead."

npm Deprecate instructions

Tags:

Npm