作为包所有者或合作者,如果你的包没有依赖,你可以使用 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.

注意:从包中删除所有协作者或团队不会取消发布它。

¥Note: Removing all the collaborators or teams from the package will not unpublish it.

取消发布包

¥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>

    ¥Navigate to the package page for the package you want to unpublish, replacing <your-package-name> with the name of your package: https://www.npmjs.com/package/<your-package-name>.

  3. 单击“设置”。

    ¥Click Settings.

    Screenshot showing the admin tab on a package page
  4. 在 "删除包" 下,单击 Delete package

    ¥Under "delete package", click Delete package.

    Screenshot showing the admin tab on a package page

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

    ¥Note: If you cannot delete the package because it does not meet the unpublishing requirements, then the delete package option will not be available. Instead, you will be prompted to deprecate the package.

  5. 如果你确定要继续,请输入你的包名称并单击 Delete package

    ¥If you are sure that you want to continue, enter your package name and click Delete package.

    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 支持。如果你是企业客户,请 联系企业支持

¥If you need help unpublishing your package, please 联系 npm 支持. If you are an Enterprise customer, please 联系企业支持.

注意:如果你取消发布整个包,则必须在 24 小时后才能发布该包的任何新版本。

¥Note: If you unpublish an entire package, you may not publish any new versions of that package until 24 hours have passed.

取消发布包的单个版本

¥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:

  • 不小心发布了一些东西。

    ¥Published something accidentally.

  • 想测试 npm。

    ¥Wanted to test npm.

  • 发布内容你 不打算公开

    ¥Published content you didn't intend to be public.

  • 想要重命名一个包。(重命名包的唯一方法是以新名称重新发布它)

    ¥Want to rename a package. (The only way to rename a package is to re-publish it under a new name)

注意:package-name@version 是唯一的,不能通过取消发布和重新发布来重复使用。我们建议改为发布次要版本更新。

¥Note: package-name@version is unique, and cannot be reused by unpublishing and re-publishing it. We recommend publishing a minor version update instead.

何时弃用

¥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".

npm 中文网 - 粤ICP备13048890号