目录

你可以从网站或命令行管理用户账户个人资料的设置。

🌐 You can manage settings for your user account profile from the web or command line.

从网站管理用户账户个人资料设置

🌐 Managing user account profile settings from the web

在网站上,你可以更改以下用户个人资料设置:

🌐 From the web, you can change the following user profile settings:

  • 头像
  • 密码
  • 全名
  • GitHub 账户链接
  • 添加到包元数据的电子邮件地址
  • 双重身份验证状态
  1. 在 npm“登录”页面上,输入您的帐户详细信息并单击登录 Screenshot of npm login dialog
  2. 在页面的右上角,点击您的个人资料照片,然后点击帐户 Screenshot of account settings selection in user menu

链接你的 npm 和 GitHub 账户

🌐 Linking your npm and GitHub accounts

  1. 在账户设置页面,你会找到一个用于关联你的 GitHub 账户的按钮。点击它。

    Screenshot of linking from Account Setting without any accounts linked
  2. 如果你当前未登录 GitHub,系统将提示你完成身份验证流程。

    GitHub login form
  3. 成功登录后,或者如果你已经有一个活跃的浏览器会话,你将会被提示“授权 npm 账户关联”,点击该按钮。

    Landing page to authorize the installation of the npm account linking app
  4. 你将被重定向到 npm,并且该链接将在你的设置中显示为成功。

    Screenshot of linking from Account Setting with successfully linked GitHub account

从 npm 中删除你的 GitHub 账户

🌐 Removing your GitHub account from npm

  1. 在账户设置页面,你会找到一个删除你的GitHub账户的按钮。点击它。

    Screenshot of linking from Account Setting with a cursor hovering over remove button

    注意:点击移除只会从你的 npm 账户中移除链接。你需要从你的 GitHub 应用授权设置 获取 revoke 权限,才能永久地从你的 GitHub 账户中移除该集成

从命令行管理用户账户个人资料设置

🌐 Managing user account profile settings from the command line

注意: 要通过命令行更改你的账户设置,你的 npm 客户端必须是 5.5.1 或更高版本。要更新到最新版本的 npm,请在命令行中运行 npm install npm@latest -g

从命令行查看用户账户个人资料设置

🌐 Viewing user account profile settings from the command line

要从 CLI 查看你的用户个人资料设置,请在命令行上运行以下命令:

🌐 To view your user profile settings from the CLI, on the command line, run the following command:

npm profile get Screenshot of command-line interface profile settings table

从命令行更新用户账户个人资料设置

🌐 Updating user account profile settings from the command line

在 CLI 中,你可以更改用户账户的以下属性:

🌐 From the CLI, you can change the following properties for your user account:

  • email
  • two-factor auth
  • fullname
  • homepage
  • freenode
  • password
  1. 在命令行中,输入以下命令,将 property 替换为属性名称,将 value 替换为新值:

    npm profile set <prop> <value>
  2. 出现提示时,提供你当前的密码。

  3. 如果你在账户上启用了双重身份验证,则在出现提示时输入一次性密码。

有关更多详情,请参阅 profile 命令行文档

🌐 For more details, see the profile command line documentation.

从命令行设置密码

🌐 Setting a password from the command line

  1. 在命令行上,键入以下命令:
npm profile set password
  1. 出现提示时,提供你当前的密码。
  2. 出现提示时,键入新密码。

为了保护你的账户,当你从命令行重置密码时,它必须:

🌐 To protect your account, when you reset your password from the command line, it must:

  • 超过 10 个字符
  • 不包含你的用户名的一部分
  • 未出现在“Have I Been Pwned”泄露数据库中

从命令行配置双重身份验证

🌐 Configuring two-factor authentication from the command line

在你的账户上启用双重身份验证有助于防止未经授权访问你的账户和包。

🌐 Enabling two-factor authentication on your account helps protect against unauthorized access to your account and packages.

要从命令行启用、配置和禁用双重身份验证,请参阅“配置双重身份验证”.

🌐 To enable, configure, and disable two-factor authentication from the command line, see "Configuring two-factor authentication".

目录