目录

作为包的所有者或协作者,如果你的包没有依赖,你可以使用 CLI 将其从 npm 注册表中永久删除。你可以在最初发布后的 72 小时内撤销发布;超过 72 小时,如果符合某些条件,仍然可以撤销发布你的包。

🌐 As a package owner or collaborator, if your package has no dependents, you can permanently remove it from the npm registry by using the CLI. You can unpublish within 72 hours of the initial publish; beyond 72 hours, you can still unpublish your package if it meets certain criteria.

这些标准是为了避免破坏 JavaScript 包生态系统。如果你无法撤回你的包,你可以改为弃用它

🌐 These criteria are set to avoid damaging the JavaScript package ecosystem. If you cannot unpublish your package, you can deprecate it instead.

注意: 从软件包中移除所有协作者或团队不会取消发布该软件包。

取消发布包

🌐 Unpublishing a package

如果你想从注册表中完全删除某个软件包的所有版本,可以将其完全下架。这将从注册表中删除该软件包,并且将无法再安装。

🌐 If you want to completely remove all versions of a package from the registry, you can unpublish it completely. This will delete it from the registry and it will be unable to be installed.

要取消发布一个软件包,你必须符合 包取消发布规则 的要求。

🌐 To unpublish a package, you must meet the requirements of the package unpublishing rules.

使用网站

🌐 Using the website

  1. 在 npm“登录”页面上,输入您的帐户详细信息并单击登录 Screenshot of npm login dialog
  2. 导航到你想要取消发布的包的页面,将 <your-package-name> 替换为你的包的名称:https://www.npmjs.com/package/<your-package-name>

  3. 点击 设置

    Screenshot showing the admin tab on a package page
  4. 在“删除软件包”下,点击 删除软件包

    Screenshot showing the admin tab on a package page

    注意: 如果你无法删除该软件包,因为它不符合 取消发布要求,则删除软件包的选项将不可用。相反,系统会提示你废弃该软件包

  5. 如果你确定要继续,请输入你的软件包名称,然后点击 删除软件包

    Screenshot showing the admin tab on a package page

使用命令行

🌐 Using the command line

要取消发布整个软件包,请运行以下命令,将 <package-name> 替换为你的软件包名称:

🌐 To unpublish an entire package, run the following command, replacing <package-name> with the name of your package:

npm unpublish <package-name> -f

如果你启用了 两步验证 进行写入操作,你需要在 unpublish 命令 --otp=123456 中添加一次性密码(其中 123456 是你的认证器应用生成的代码)。

🌐 If you have two-factor authentication enabled for writes, you will need to add a one-time password to the unpublish command, --otp=123456 (where 123456 is the code from your authenticator app).

如果你需要帮助取消发布你的软件包,请 联系 npm 支持。如果你是企业客户,请 联系企业支持

注意: 如果你取消发布整个软件包,在 24 小时内你将无法发布该软件包的新版本。

取消发布包的单个版本

🌐 Unpublishing a single version of a package

如果你想删除某个软件包的单个版本,你可以取消发布该版本而不影响其他版本。这将仅从注册表中删除该版本,并且无法再安装。此选项仅通过 npm CLI 提供。

🌐 If you want to remove a single version of a package, you can unpublish one version without affecting the others. This will delete only that version from the registry and it will be unable to be installed. This option is only available via the npm CLI.

使用命令行

🌐 Using the command line

要取消发布包的单个版本,请运行以下命令,将 <package-name> 替换为你的包名称,将 <version> 替换为你的版本号:

🌐 To unpublish a single version of a package, run the following command, replacing <package-name> with the name of your package, and <version> with your version number:

npm unpublish <package-name>@<version>

何时取消发布

🌐 When to unpublish

取消发布一个包会将该包永久从注册表中移除,因此其他用户将无法再安装该包。一旦包被取消发布,24小时内无法使用相同的名称重新发布。如果你误取消发布了一个包,建议使用不同的名称重新发布,或者对于已经取消发布的版本,可以增加版本号后再次发布。

🌐 Unpublishing a package permanently removes the package from the registry so it is no longer available for other users to install. Once a package is unpublished, republishing under the same name is blocked for 24 hours. 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.

你可能想要取消发布包,因为你:

🌐 You might want to unpublish a package because you:

  • 不小心发布了一些东西。
  • 想测试 npm。
  • 已发布内容你 本不打算公开
  • 想要重命名一个包。(重命名包的唯一方法是以新名称重新发布它)

注意: package-name@version 是唯一的,不能通过下架再重新发布来重复使用。我们建议发布小版本更新。

何时弃用

🌐 When to deprecate

如果你不再有兴趣维护某个软件包,但希望它仍然可供用户安装,或者你的软件包有依赖,我们建议将其 弃用。要了解如何弃用软件包,请参阅“弃用和取消弃用包或包版本”。

🌐 If you are no longer interested in maintaining a package, but want it to remain available for users to install, or if your package has dependents, we'd recommend deprecating it. To learn about how to deprecate a package, see "Deprecating and undeprecating packages or package versions".

目录