`npm publish -f` 有解决方法吗

Is there a workaround for `npm publish -f`

现在 npm publish -f 已弃用,是否有解决方法或软件包可以在目标版本发布后 覆盖

我知道 semver;我还想要npm publish -f.

有人在 npm 的 github 问题上说过:

@nmrony You cannot overwrite previously-published packages anymore (since February 2014, if I recall correctly).

https://github.com/npm/npm/issues/8305#issuecomment-236412989

这可能不可行,但有一个矫枉过正的方法

npm unpublish --force - 将删除您的整个项目

等待 24 小时

npm publish

您可以取消发布特定版本,然后重新发布它:

npm unpublish myModule@1.2.3

然后重新发布版本。

如果模块托管在您自己的 npm 存储库上,这将无限期地工作,但根据 this,如果托管在 [=11= 上,您可以在时间限制(72 小时)内执行此操作].

根据npm docs这个未发布的版本不能重新发布,打补丁版本发布

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.

所以:

npm unpublish
npm version patch
npm publish

会完成任务的。