npm-access

Set access level on published packages设置已发布包的访问级别

Synopsis


npm access list packages [<user>|<scope>|<scope:team> [<package>]
npm access list collaborators [<package> [<user>]]
npm access get status [<package>]
npm access set status=public|private [<package>]
npm access set mfa=none|publish|automation [<package>]
npm access grant <read-only|read-write> <scope:team> [<package>]
npm access revoke <scope:team> [<package>]

Note: This command is unaware of workspaces.注意:此命令不知道工作空间。

Description描述

Used to set access controls on private packages.用于设置专用程序包的访问控制。

For all of the subcommands, npm access will perform actions on the packages in the current working directory if no package name is passed to the subcommand.对于所有子命令,如果没有将包名称传递给子命令,则npm access将对当前工作目录中的包执行操作。

  • public / restricted (deprecated): Set a package to be either publicly accessible or restricted.将包设置为可公开访问或受限制。

  • grant / revoke (deprecated): Add or remove the ability of users and teams to have read-only or read-write access to a package.添加或删除用户和团队对包具有只读或读写访问权限的功能。

  • 2fa-required / 2fa-not-required (deprecated): Configure whether a package requires that anyone publishing it have two-factor authentication enabled on their account.配置包是否要求发布该包的任何人在其帐户上启用双因素身份验证。

  • ls-packages (deprecated): Show all of the packages a user or a team is able to access, along with the access level, except for read-only public packages (it won't print the whole registry listing)显示用户或团队能够访问的所有包以及访问级别,只读公共包除外(它不会打印整个注册表列表)

  • ls-collaborators (deprecated): Show all of the access privileges for a package. 显示包的所有访问权限。Will only show permissions for packages to which you have at least read access. 将仅显示您至少有读取权限的程序包的权限。If <user> is passed in, the list is filtered only to teams that user happens to belong to.如果传入了<user>,则列表将仅筛选到用户碰巧属于的团队。

  • edit (not implemented)编辑(未实现)

Details详细信息

npm access always operates directly on the current registry, configurable from the command line using --registry=<registry url>.始终直接在当前注册表上操作,可使用--registry=<registry url>从命令行进行配置。

Unscoped packages are always public.无作用域的包始终是公开的

Scoped packages default to restricted, but you can either publish them as public using npm publish --access=public, or set their access as public using npm access public after the initial publish.作用域包默认为受限包,但您可以使用npm publish --access=public将其发布为public,也可以在初始发布后使用npm access public将其访问设置为public

You must have privileges to set the access of a package:您必须具有设置包访问权限的权限:

  • You are an owner of an unscoped or scoped package.您是未限定范围或限定范围的包的所有者。
  • You are a member of the team that owns a scope.您是拥有作用域的团队的成员。
  • You have been given read-write privileges for a package, either as a member of a team or directly as an owner.您已被授予包的读写权限,无论是作为团队成员还是直接作为所有者。

If you have two-factor authentication enabled then you'll be prompted to provide a second factor, or may use the --otp=... option to specify it on the command line.如果启用了双因素身份验证,则系统将提示您提供第二个因素,或者可以使用--otp=...选项,以便在命令行中指定它。

If your account is not paid, then attempts to publish scoped packages will fail with an HTTP 402 status code (logically enough), unless you use --access=public.如果您的帐户未付款,则尝试发布范围内的包将失败,并显示HTTP 402状态代码(逻辑上足够),除非您使用--access=public

Management of teams and team memberships is done with the npm team command.团队和团队成员的管理是通过npm team命令完成的。

Configuration配置

json

  • Default: false
  • Type: Boolean

Whether or not to output JSON data, rather than the normal output.是否输出JSON数据,而不是正常输出。

  • In npm pkg set it enables parsing set values with JSON.parse() before saving them to your package.json.npm pkg set中,它允许在将集合值保存到您的package.json之前使用JSON.parse()解析集合值。

Not supported by all npm commands.并非所有npm命令都支持。

otp

  • Default: null
  • Type: null or String

This is a one-time password from a two-factor authenticator. 这是来自双因素身份验证程序的一次性密码。It's needed when publishing or changing package permissions with npm access.在发布或更改具有npm access的包权限时需要它。

If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one.如果未设置,并且注册表响应失败并询问一次性密码,则npm将在命令行提示输入一次性密码。

registry

The base URL of the npm registry.npm注册表的基本URL。

See Also