Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming a published NPM module

Tags:

npm

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 like to leave people who have already installed it in the lurch.

like image 933
thekevinscott Avatar asked Feb 06 '15 17:02

thekevinscott


People also ask

Does npm publish overwrite?

By default npm will publish to the public registry. This can be overridden by specifying a different default registry or using a scope in the name (see package. json ).

What does publishing to npm mean?

When you run npm publish , npm bundles up all the files in the current directory. It makes a few decisions for you about what to include and what to ignore. To make these decisions, it uses the contents of several files in your project directory.


2 Answers

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

like image 54
Peter Flannery Avatar answered Sep 22 '22 20:09

Peter Flannery


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. 
like image 23
Ujjwal Avatar answered Sep 22 '22 20:09

Ujjwal