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

Package detail

libnpmaccess

npm8.5mISC10.0.3

programmatic library for npm access commands

readme

libnpmaccess

npm version license CI - libnpmaccess

libnpmaccess is a Node.js library that provides programmatic access to the guts of the npm CLI's npm access command. This includes managing account mfa settings, listing packages and permissions, looking at package collaborators, and defining package permissions for users, orgs, and teams.

Example

const access = require('libnpmaccess')
const opts = { '//registry.npmjs.org/:_authToken: 'npm_token }

// List all packages @zkat has access to on the npm registry.
console.log(Object.keys(await access.getPackages('zkat', opts)))

API

opts for all libnpmaccess commands

libnpmaccess 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.

spec parameter for all libnpmaccess commands

spec must be an npm-package-arg-compatible registry spec.

access.getCollaborators(spec, opts) -> Promise<Object>

Gets collaborators for a given package

access.getPackages(user|scope|team, opts) -> Promise<Object>

Gets all packages for a given user, scope, or team.

Teams should be in the format scope:team or @scope:team

Users and scopes can be in the format @scope or scope

access.getVisibility(spec, opts) -> Promise<Object>

Gets the visibility of a given package

access.removePermissions(team, spec, opts) -> Promise<Boolean>

Removes the access for a given team to a package.

Teams should be in the format scope:team or @scope:team

access.setAccess(package, access, opts) -> Promise<Boolean>

Sets access level for package described by spec.

The npm registry accepts the following access levels:

  • public: package is public
  • private: package is private

The npm registry also only allows scoped packages to have their access level set.

access.setMfa(spec, level, opts) -> Promise<Boolean>`

Sets the publishing mfa requirements for a given package. Level must be one of the following:

  • none: mfa is not required to publish this package.
  • publish: mfa is required to publish this package, automation tokens cannot be used to publish.
  • automation: mfa is required to publish this package, automation tokens may also be used for publishing from continuous integration workflows.

access.setPermissions(team, spec, permissions, opts) -> Promise<Boolean>`

Sets permissions levels for a given team to a package.

Teams should be in the format scope:team or @scope:team

The npm registry accepts the following permissions:

  • read-only: Read only permissions
  • read-write: Read and write (aka publish) permissions

changelog

Changelog

11.6.2 (2025-10-08)

Bug Fixes

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 highest 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