Now that npm publish -f
is deprecated, is there a workaround or a package that makes it possible to overwrite a target version after it's been published?
I know about semver; I still want npm publish -f
.
Now that npm publish -f
is deprecated, is there a workaround or a package that makes it possible to overwrite a target version after it's been published?
I know about semver; I still want npm publish -f
.
You can unpublish a specific version, and then republish it:
npm unpublish myModule@1.2.3
And then republish the version.
This works if the module is hosted on your own npm repo, but for registry.npmjs.org
, you won't be able to reuse the version number after unpublishing, and there's a time-limit (72 hours) after which you can no longer unpublish. See the npm Unpublish Policy.
someone said this on npm's github issue:
@nmrony You cannot overwrite previously-published packages anymore (since February 2014, if I recall correctly).
https://github.com/npm/npm/issues/8305#issuecomment-236412989
According to npm docs this unpublished versions cannot be republished,bump a patch version and publish
Once a package is unpublished, it cannot be republished. If you’ve unpublished a package by mistake, we’d recommend publishing again under a different name, or for unpublished versions, bumping the version number and publishing again.
So:
npm unpublish
npm version patch
npm publish
will do the job.
This will probably not be viable but there's an overkill method
npm unpublish --force
- will delete your entire project
wait 24 hours
npm publish
I also faced similar issue.I published a new package with new version but same content.
npm publish --access public (version - 0.1.1)
Now, delete the original package.
npm unpublish -f package_name@0.1.0
wait 24 hours republish the original package & delete the new package.
npm publish --access public (version - 0.1.0)
npm unpublish -f package_name@0.1.1
Your package user will not find original version for 24 hours, so package manager will show drop down to choose other version & most will go with latest version.