npm-adduser

添加注册表用户账户

选择命令行版本:

概要

🌐 Synopsis

npm adduser
alias: add-user

注意:此命令不支持工作区。

🌐 Note: This command is unaware of workspaces.

描述

🌐 Description

在指定的注册表中创建新用户,并将凭据保存到 .npmrc 文件中。如果未指定注册表,将使用默认注册表(参见 registry)。

🌐 Create a new user in the specified registry, and save the credentials to the .npmrc file. If no registry is specified, the default registry will be used (see registry).

在为你的 auth-type 使用 legacy 时,用户名、密码和电子邮件会从提示中读取。

🌐 When using legacy for your auth-type, the username, password, and email are read in from prompts.

配置

🌐 Configuration

registry

  • 默认: "https://registry.npmjs.org/"
  • 类型:网址

npm 注册表的基本 URL。

🌐 The base URL of the npm registry.

scope

  • 默认:当前项目的范围(如果有)或
  • 类型:字符串

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

🌐 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" 或 "web"

使用 login 时应使用什么认证策略。请注意,如果提供了 otp 配置,此值将始终设置为 legacy

🌐 What authentication strategy to use with login. Note that if an otp config is given, this value will always be set to legacy.

也可以看看

🌐 See Also