npm-adduser

添加注册表用户账户

选择命令行版本:

概要

¥Synopsis

npm adduser
aliases: login, add-user

注意:此命令对工作区无感知。

¥Note: This command is unaware of workspaces.

描述

¥Description

在指定的注册表中创建或验证名为 <username> 的用户,并将凭据保存到 .npmrc 文件中。如果未指定注册表,将使用默认注册表(参见 config)。

¥Create or verify a user named <username> in the specified registry, and save the credentials to the .npmrc file. If no registry is specified, the default registry will be used (see config).

从提示中读入用户名、密码和电子邮件。

¥The username, password, and email are read in from prompts.

要重设密码,请转到 https://www.npmjs.com/forgot

¥To reset your password, go to https://www.npmjs.com/forgot

要更改你的电子邮件地址,请转到 https://www.npmjs.com/email-edit

¥To change your email address, go to https://www.npmjs.com/email-edit

你可以使用同一用户账户多次使用此命令在新机器上进行授权。在新机器上进行身份验证时,用户名、密码和电子邮件地址都必须与你现有的记录匹配。

¥You may use this command multiple times with the same user account to authorize on a new machine. When authenticating on a new machine, the username, password and email address must all match with your existing record.

npm loginadduser 的别名,其行为方式完全相同。

¥npm login is an alias to adduser and behaves exactly the same way.

配置

¥Configuration

registry

npm 注册表的基本 URL。

¥The base URL of the npm registry.

scope

  • 默认值:当前项目的范围(如果有)或 ""

    ¥Default: the scope of the current project, if any, or ""

  • 类型:字符串

    ¥Type: String

将操作与范围注册表的作用域相关联。

¥Associate an operation with a scope for a scoped registry.

在登录或退出私有注册表时很有用:

¥Useful when logging in to or out of a private registry:

# log in, linking the scope to the custom registry
npm login --scope=@mycorp --registry=https://registry.mycorp.com
# log out, removing the link and the auth token
npm logout --scope=@mycorp

这将导致 @mycorp 映射到注册表,以便将来安装根据模式 @mycorp/package 指定的包。

¥This will cause @mycorp to be mapped to the registry for future installation of packages specified according to the pattern @mycorp/package.

这也将导致 npm init 创建一个范围包。

¥This will also cause npm init to create a scoped package.

# accept all defaults, and create a package named "@foo/whatever",
# instead of just named "whatever"
npm init --scope=@foo --yes

auth-type

  • 默认值:"legacy"

    ¥Default: "legacy"

  • 类型:"legacy"、"web"、"sso"、"saml"、"oauth" 或 "webauthn"

    ¥Type: "legacy", "web", "sso", "saml", "oauth", or "webauthn"

注意:auth-type 值 "sso"、"saml"、"oauth" 和 "webauthn" 将在未来版本中删除。

¥NOTE: auth-type values "sso", "saml", "oauth", and "webauthn" will be removed in a future version.

login 使用什么身份验证策略。

¥What authentication strategy to use with login.

也可以看看

¥See Also

npm 中文网 - 粤ICP备13048890号