Renaming a Package That Already Has Users
No major registry lets you simply rename a package in place. A rename is really two packages: a new name you publish going forward, and an old name you wind down carefully so nobody is stranded or redirected to something unsafe. This plan sets out the steps, an illustrative timeline, and the traps that make renames go wrong.
Step 1: be sure, and pick the name once
A rename costs every user a change. Do it for a lasting reason, such as a trademark complaint, a name that misleads, or merging several packages, rather than for taste. Then check the new name on every registry you publish to, along with the obvious misspellings, and reserve it in each. On npm, consider a scope you control (@example/widget), which makes impersonation harder.
Step 2: publish under the new name
- Change the name in the manifest. In Python, also decide whether the import name changes; if it does, that is a bigger migration than the distribution name.
- Publish a first version that is functionally identical to the latest version of the old package. Using the same version number, or the next one, makes the relationship obvious.
- Update the README, repository description and documentation to the new name.
Step 3: point the old name at the new one
| Ecosystem | How to signal the move |
|---|---|
| npm | npm deprecate old-widget "Renamed to @example/widget"; the message is shown on install |
| PyPI | Publish a final release of the old name whose README explains the move; optionally make it depend on the new package and re-export it |
| Go | Add a // Deprecated: comment to the old module's module line in go.mod and tag a release |
| crates.io | Publish a final version with a README notice and mark the old crate's items deprecated |
A thin compatibility release of the old name, which depends on and re-exports the new one, lets existing users keep receiving fixes until they switch.
# old name's final pyproject.toml (illustrative)
[project]
name = "old-widget"
version = "3.0.0"
dependencies = ["example-widget>=3.0"]
Illustrative timeline
- Week 0: announce the rename in the changelog and an issue; publish the new name.
- Week 1: deprecate the old name with a message pointing to the new one; publish the compatibility release.
- Months 1-6: keep shipping fixes under the new name; the compatibility package picks them up through its range.
- After that: stop updating the old name, but do not unpublish or delete it.
Traps to avoid
- Releasing the old name. If you give up or delete the old name, someone else may be able to register it and publish code that existing lockfiles or install commands would fetch. Keep control of it indefinitely.
- Breaking changes in the same step. Rename first, then change the API in a later major. Doing both at once makes migration and bug reports much harder to untangle.
- Forgetting the outside links. Update badges, documentation sites, examples and any CI templates others copy.
See also package naming conventions and typosquatting package names.