Is there any way to rename an NPM module that has already been published? I want to change the name of my module to more accurately match the API it exposes but would not li
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.
I once was in this situation. I published a package with the name bowser-or-node
instead of browser-or-node
.
There's no way to rename a package, you have to deprecate and publish a new package.
Although there's one other option. If you just published your package (less than 24 hours from time of publish) and if you're sure you're okay with deleting the package and publish a new one with the right name, you can go ahead and do it. But NPM won't allow you to delete the package once it's been 24 hours since the time of publish.
Fortunately I figured out that I published with the wrong name in less than 20 minutes. So I just deleted and published again with a new name.
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
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
Something marvelous just happened to me: I managed to rename a package. It was originally known as stdout-renderer, but I changed every possible occurence of the name, and republished it after having deprecated the original and voila it shows up under its new name (cli-artist) undeprecated in the newly updated list. I'm not sure which field to change, but I would imagine it be in package.json because that's the only one where the casing matched in my case.
hope that helps!