作为包所有者或维护者,你可以使用 npm 网站或命令行将不再希望维护的包的所有权转让给另一个受信任的 npm 用户。

🌐 As a package owner or maintainer, you can transfer ownership of a package you no longer wish to maintain to another trusted npm user using either the npm website or the command line.

有关 npm 支持如何处理用户之间的包名称争议的更多信息,你可以参考 npm 的 软件包名称争议政策

🌐 For more information on how npm support handles package name disputes between users, you can refer to npm's package name dispute policy.

**注意:**你无法将带作用域的包转移到另一个用户账户或组织,因为包的作用域就是用户账户或组织的名称。你需要在新的作用域中创建一个新包。

在网站上将包从用户账户转移到另一个用户账户

🌐 Transferring a package from a user account to another user account on the website

要将你拥有或维护的包转让给其他用户,请执行以下步骤:

🌐 To transfer a package you own or maintain to another user, follow these steps:

  1. 导航到你想要转移的包的包页面,将 <your-package-name> 替换为你的包名称:https://www.npmjs.com/package/<your-package-name>

  2. 在软件包的管理员标签下,在“维护者”中输入新维护者的 npm 用户名。

    Screenshot showing text field to invite maintainers
  3. 点击“邀请”。

  4. 要将自己从维护者中移除,在维护者列表中,点击用户名旁边的“x”即可。

    Screenshot showing maintainer list

在命令行上将包从用户账户转移到另一个用户账户

🌐 Transferring a package from a user account to another user account on the command line

要使用 CLI 将包转移给另一个 npm 用户,请运行 npm owner add 命令,并将 <their-username> 替换为另一个用户的 npm 用户名。系统会向另一个用户发送电子邮件邀请。在用户接受邀请后,运行 npm owner rm 命令,并将 <your-username> 替换为你的 npm 用户名:

🌐 To transfer a package to another npm user using the CLI, run the npm owner add command replacing <their-username> with the other user's npm username. An email invitation is sent to the other user. After the user has accepted the invitation, run the npm owner rm command replacing <your-username> with your npm username:

npm owner add <their-username> <package-name>
# new maintainer accepts invitation
npm owner rm <your-username> <package-name>

如果你已为写入操作启用两步验证码,请在命令中添加一次性密码 --otp=123456(其中 123456 是你的身份验证器应用生成的代码)。

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

npm owner add <their-username> <package-name> --otp=123456
# new maintainer accepts invitation
npm owner rm <your-username> <package-name> --otp=123456