libnpmteam

npm Team management APIs

ISC 36 个版本
安装
npm install libnpmteam
yarn add libnpmteam
pnpm add libnpmteam
bun add libnpmteam
README

libnpmteam

npm version license CI - libnpmteam

libnpmteam is a Node.js library that provides programmatic access to the guts of the npm CLI's npm team command and its various subcommands.

Table of Contents

Install

$ npm install libnpmteam

Example

const team = require('libnpmteam')

// List all teams for the @npm org.
console.log(await team.lsTeams('npm'))

API

opts for libnpmteam commands

libnpmteam uses npm-registry-fetch. All options are passed through directly to that library, so please refer to its own opts documentation for options that can be passed in.

A couple of options of note for those in a hurry:

  • opts.token - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs.
  • opts.otp - certain operations will require an OTP token to be passed in. If a libnpmteam command fails with err.code === EOTP, please retry the request with {otp: <2fa token>}

> team.create(team, [opts]) -> Promise

Creates a team named team. Team names use the format @<scope>:<name>, with the @ being optional.

Additionally, opts.description may be passed in to include a description.

Example
await team.create('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team now exists.

> team.destroy(team, [opts]) -> Promise

Destroys a team named team. Team names use the format @<scope>:<name>, with the @ being optional.

Example
await team.destroy('@npm:cli', {token: 'myregistrytoken'})
// The @npm:cli team has been destroyed.

> team.add(user, team, [opts]) -> Promise

Adds user to team.

Example
await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat now belongs to the @npm:cli team.

> team.rm(user, team, [opts]) -> Promise

Removes user from team.

Example
await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'})
// @zkat is no longer part of the @npm:cli team.

> team.lsTeams(scope, [opts]) -> Promise

Resolves to an array of team names belonging to scope.

Example
await team.lsTeams('@npm', {token: 'myregistrytoken'})
=>
[
  'npm:cli',
  'npm:web',
  'npm:registry',
  'npm:developers'
]

> team.lsTeams.stream(scope, [opts]) -> Stream

Returns a stream of teams belonging to scope.

For a Promise-based version of these results, see team.lsTeams().

Example
for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) {
  console.log(team)
}

// outputs
// npm:cli
// npm:web
// npm:registry
// npm:developers

> team.lsUsers(team, [opts]) -> Promise

Resolves to an array of usernames belonging to team.

For a streamed version of these results, see team.lsUsers.stream().

Example
await team.lsUsers('@npm:cli', {token: 'myregistrytoken'})
=>
[
  'iarna',
  'zkat'
]

> team.lsUsers.stream(team, [opts]) -> Stream

Returns a stream of usernames belonging to team.

For a Promise-based version of these results, see team.lsUsers().

Example
for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) {
  console.log(user)
}

// outputs
// iarna
// zkat
版本列表
9.0.0 2026-07-08
9.0.0-pre.0 2026-06-19
8.0.2 2025-09-24
8.0.1 2025-05-15
8.0.0 2024-12-16
8.0.0-pre.0 2024-11-26
7.0.0 2024-10-03
6.0.5 2024-05-15
6.0.4 2024-04-30
6.0.3 2024-04-25
6.0.2 2024-04-03
6.0.1 2023-12-06
6.0.0 2023-08-31
6.0.0-pre.0 2023-08-31
5.0.4 2024-02-28
5.0.3 2023-02-15
5.0.2 2023-02-07
5.0.1 2022-12-07
5.0.0 2022-10-19
5.0.0-pre.1 2022-10-19
5.0.0-pre.0 2022-09-12
4.0.4 2022-08-31
4.0.3 2022-04-07
4.0.2 2022-03-17
4.0.1 2022-03-09
4.0.0 2022-02-24
3.0.1 2022-01-27
3.0.0 2022-01-05
2.0.4 2021-06-02
2.0.3 2021-04-22
2.0.2 2020-11-03
2.0.1 2020-03-02
2.0.0 2020-03-02
1.0.2 2019-07-16
1.0.1 2018-08-24
1.0.0 2018-08-22