npm 中文文档 npm 中文文档
指南
npmjs.com (opens new window)
指南
npmjs.com (opens new window)
  • 快速入门

    • npm 是什么?
    • npm 安装和更新
    • npm 防止权限错误
    • npm package.json 文件
    • npm 安装包
    • npm 更新包
    • npm 卸载包
    • npm 创建 Node.js 模块
    • npm 发布和更新包
    • npm 使用语义化版本
    • npm 使用 Dist-tags 标记包
    • npm 包和模块的了解
  • 命令行
  • 配置 npm

Managing your profile settings


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:

Avatar
Password
Full name
Link GitHub Account
Link Twitter Account
Email address added to package metadata
Two-factor authentication status

Log in to npm with your user account.Screenshot of npm login dialog

In the upper right corner of the page, click your profile picture, then click Account.Screenshot of account settings selection in user menu

Linking your npm and GitHub accounts


On the account settings page, you will find a button to link your GitHub account. Click that.

Screenshot of linking from Account Setting without any accounts linked

If you are not currently logged in to GitHub you will be prompted to go through the authentication flow.

GitHub login form

After successfully logging in, or if you already had an active browser sessions, you will be prompted to "authorize npm account link", click the button.

Landing page to authorize the installation of the npm account linking app

You will be redirected to npm and the link will show as successful in your settings.

Screenshot of linking from Account Setting with successfully linked GitHub account

Linking your npm and Twitter accounts


On the account settings page, you will find a button to link your Twitter account. Click that.

Screenshot of linking from Account Setting without any accounts linked

If you are not currently logged in to Twitter you will be prompted to go through the authentication flow. Click "Log in"

Twitter login form

After successfully logging in, or if you already had an active browser sessions, you will be prompted to "Authorize app", click the button.

Landing page to authorize the installation of the npm account linking app

You will be redirected to npm and the link will show as successful in your settings.

Screenshot of linking from Account Setting with successfully linked Twitter account

Disconnecting your GitHub account from npm


On the account settings page, you will find a button to disconnect your GitHub account. Click that.

Screenshot of linking from Account Setting with a cursor hovering over disconnect
Note: Clicking disconnect will only disconnect the link from your npm account. You need to revokepermissions from your GitHub app authorization settings to permanently remove the integration from your GitHub account

Disconnecting your Twitter account from npm


On the account settings page, you will find a button to disconnect your GitHub account. Click that.

Screenshot of linking from Account Setting with a cursor hovering over disconnect
Note: Clicking disconnect will only disconnect the link from your npm account. You need to revokepermissions from your Twitter connect apps management page to permanently remove the integration from your Twitter account

Managing user account profile settings from the command line


Note:Your npm client must be version 5.5.1 or higher to change your account settings from the CLI. To update to the latest version of npm, on the command line, run npm install npm@latest -g

Viewing user account profile settings from the command line


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


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

email
two-factor auth
fullname
homepage
freenode
password

On the command line, type the following command, replacing propertywith the name of the property, and valuewith the new value:

  1. ``` sh
  2. npm profile set <prop> <value>
  3. ```

When prompted, provide your current password.

If you have enabled two-factor authentication on your account, when prompted, enter a one-time password.

For more details, see the profilecommand line documentation .

Setting a password from the command line


On the command line, type the following command:

npm profile set password

When prompted, provide your current password.

When prompted, type a new password.

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

be longer than 10 characters
not contain part of your username
not be in the "Have I Been Pwned " breach database

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 ".
Last Updated: 2023-05-15 10:22:02