Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

libnpmorg

npm3.2mISC8.0.1

Programmatic api for npm org commands

libnpm, npm, package manager, api, orgs, teams

readme

libnpmorg

npm version license CI - libnpmorg

libnpmorg is a Node.js library for programmatically accessing the npm Org membership API.

Table of Contents

Example

const org = require('libnpmorg')

console.log(await org.ls('myorg', {token: 'deadbeef'}))
=>
Roster {
  zkat: 'developer',
  iarna: 'admin',
  isaacs: 'owner'
}

Install

$ npm install libnpmorg

API

opts for libnpmorg commands

libnpmorg 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 libnpmorg command fails with err.code === EOTP, please retry the request with {otp: <2fa token>}

> org.set(org, user, [role], [opts]) -> Promise

The returned Promise resolves to a Membership Detail object.

The role is optional and should be one of admin, owner, or developer. developer is the default if no role is provided.

org and user must be scope names for the org name and user name respectively. They can optionally be prefixed with @.

See also: PUT /-/org/:scope/user

Example
await org.set('@myorg', '@myuser', 'admin', {token: 'deadbeef'})
=>
MembershipDetail {
  org: {
    name: 'myorg',
    size: 15
  },
  user: 'myuser',
  role: 'admin'
}

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

The Promise resolves to null on success.

org and user must be scope names for the org name and user name respectively. They can optionally be prefixed with @.

See also: DELETE /-/org/:scope/user

Example
await org.rm('myorg', 'myuser', {token: 'deadbeef'})

> org.ls(org, [opts]) -> Promise

The Promise resolves to a Roster object.

org must be a scope name for an org, and can be optionally prefixed with @.

See also: GET /-/org/:scope/user

Example
await org.ls('myorg', {token: 'deadbeef'})
=>
Roster {
  zkat: 'developer',
  iarna: 'admin',
  isaacs: 'owner'
}

> org.ls.stream(org, [opts]) -> Stream

Returns a stream of entries for a Roster, with each emitted entry in [key, value] format.

org must be a scope name for an org, and can be optionally prefixed with @.

The returned stream is a valid Symbol.asyncIterator.

See also: GET /-/org/:scope/user

Example
for await (let [user, role] of org.ls.stream('myorg', {token: 'deadbeef'})) {
  console.log(`user: ${user} (${role})`)
}
=>
user: zkat (developer)
user: iarna (admin)
user: isaacs (owner)

changelog

Changelog

11.6.1 (2025-09-23)

Bug Fixes

11.6.0 (2025-09-03)

Features

  • bdcc10d #8359 add support for optional env var replacements in .npmrc (#8359) (@aczekajski, @owlstronaut)

    Bug Fixes

  • dd4cee9 #8539 powershell: improve argument parsing (#8539) (@alexsch01)
  • 5f18557 #8532 powershell: fix issue with modified InvocationName (#8532) (@alexsch01)
  • 9e5abf1 #8529 add redaction to log format egress (#8529) (@wraithgar)
  • 75ce64a #8524 revert handle signal exits gracefully (#8524) (@owlstronaut)
  • 5d82d0b #8469 ps1 scripts in powershell 5.1 (#8469) (@splatteredbits)

Dependencies

11.5.2 (2025-07-30)

Bug Fixes

  • 7d900c4 #8467 oidc visibility check for provenance (#8467) (@reggi, @wraithgar)

    Documentation

  • d4e56b2 #8459 update snapshot generation command (#8459) (@MikeMcC399)

11.5.1 (2025-07-24)

Bug Fixes

  • 476bf17 #8457 provenance should only default for oidc (@reggi)

11.5.0 (2025-07-24)

Features

11.4.2 (2025-06-11)

Bug Fixes

11.4.1 (2025-05-21)

Documentation

  • 3ed764a #8308 Clarify script working directory behavior (fixes #8305) (#8308) (@tarekwfa0110, @owlstronaut)

    Chores

  • 2f30251 #8314 remove references to skimdb.npmjs.com (#8314) (@shmam)
  • 9cb9d50 #8298 add contributor to changelog entry (#8298) (@wraithgar)

Dependencies

11.4.0 (2025-05-15)

Features

11.3.0 (2025-04-08)

Features

11.2.0 (2025-03-05)

Features

11.1.0 (2025-01-29)

Features

  • 7f6c997 #8009 add dry-run to deprecate/undeprecate commands (@wraithgar)
  • 1764a37 #8009 add npm undeprecate command (@wraithgar)

    Bug Fixes

  • 31455b2 #8054 publish: honor force for no dist tag and registry version check (#8054) (@reggi)
  • dc31c1b #8038 remove max-len linting bypasses (@wraithgar)
  • 8a911ff #8038 publish: disregard deprecated versions when calculating highest version (@wraithgar)
  • 7f72944 #8038 publish: accept publishConfig.tag to override highes semver check (@wraithgar)
  • ab9ddc0 #7992 sbom: deduplicate sbom dependencies (#7992) (@bdehamer)
  • f7da341 #7980 search: properly display multiple search terms (#7980) (@wraithgar)

    Documentation

  • 3644e79 #8055 update readme for Node.js versions, remove badges (#8055) (@wraithgar)
  • f1af61f #8041 fix typos in "package-json" (#8041) (@maxkoryukov)
  • e90c6fe #8051 depth flag default value (#8051) (@milaninfy)
  • 866b5ee #8030 safer documentation urls, repos, packages (#8030) (@reggi)

    Dependencies

  • 7ddfbad #8053 @npmcli/package-json@6.1.1
  • 9473a86 #8053 `spdx-license-ids@3.0.21`
  • a65e5ce #8053 @sigstore/protobuf-specs@0.3.3
  • 215ebe4 #8053 `chalk@5.4.1`

    Chores

  • 61f00e3 #8069 splits out smoke-tests from publish-dryrun tests (#8069) (@reggi)
  • 6d0f46e #8058 stop publish smoke from check git clean (#8058) (@reggi)
  • 9281ebf #8057 fix smoke tests prerelease needs separate string args (#8057) (@reggi)
  • aa202e9 #8056 smoke tests using a preid (#8056) (@reggi)
  • 18e0449 #8053 dev dependency updates (@wraithgar)
  • 859a71c #8052 update node versions for release integration tests (#8052) (@wraithgar)
  • 7e7961d #8038 bump @npmcli/eslint-config to 5.1.0 (@wraithgar)
  • workspace: @npmcli/config@10.0.1

11.0.0 (2024-12-16)

Documentation

11.0.0-pre.1 (2024-12-06)

⚠️ BREAKING CHANGES

11.0.0-pre.0 (2024-11-26)

⚠️ BREAKING CHANGES