deprecate-totp-2fa
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-access |
| 3 | section: 1 |
| 4 | description: Set access level on published packages |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v7 |
| 7 | github_path: docs/content/commands/npm-access.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v7/access |
| 10 | - /cli-documentation/v7/cli-commands/access |
| 11 | - /cli-documentation/v7/cli-commands/npm-access |
| 12 | - /cli-documentation/v7/commands/access |
| 13 | - /cli-documentation/v7/commands/npm-access |
| 14 | - /cli-documentation/v7/npm-access |
| 15 | - /cli/v7/access |
| 16 | - /cli/v7/cli-commands/access |
| 17 | - /cli/v7/cli-commands/npm-access |
| 18 | - /cli/v7/commands/access |
| 19 | - /cli/v7/npm-access |
| 20 | --- |
| 21 | |
| 22 | ### Synopsis |
| 23 | |
| 24 | ```bash |
| 25 | npm access public [<package>] |
| 26 | npm access restricted [<package>] |
| 27 | |
| 28 | npm access grant <read-only|read-write> <scope:team> [<package>] |
| 29 | npm access revoke <scope:team> [<package>] |
| 30 | |
| 31 | npm access 2fa-required [<package>] |
| 32 | npm access 2fa-not-required [<package>] |
| 33 | |
| 34 | npm access ls-packages [<user>|<scope>|<scope:team>] |
| 35 | npm access ls-collaborators [<package> [<user>]] |
| 36 | npm access edit [<package>] |
| 37 | ``` |
| 38 | |
| 39 | ### Description |
| 40 | |
| 41 | Used to set access controls on private packages. |
| 42 | |
| 43 | 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. |
| 44 | |
| 45 | - public / restricted: Set a package to be either publicly accessible or restricted. |
| 46 | |
| 47 | - grant / revoke: Add or remove the ability of users and teams to have read-only or read-write access to a package. |
| 48 | |
| 49 | - 2fa-required / 2fa-not-required: Configure whether a package requires that anyone publishing it have two-factor authentication enabled on their account. |
| 50 | |
| 51 | - ls-packages: 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) |
| 52 | |
| 53 | - ls-collaborators: 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. |
| 54 | |
| 55 | - edit: Set the access privileges for a package at once using `$EDITOR`. |
| 56 | |
| 57 | ### Details |
| 58 | |
| 59 | `npm access` always operates directly on the current registry, configurable from the command line using `--registry=<registry url>`. |
| 60 | |
| 61 | Unscoped packages are _always public_. |
| 62 | |
| 63 | 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. |
| 64 | |
| 65 | You must have privileges to set the access of a package: |
| 66 | |
| 67 | - You are an owner of an unscoped or scoped package. |
| 68 | - You are a member of the team that owns a scope. |
| 69 | - You have been given read-write privileges for a package, either as a member of a team or directly as an owner. |
| 70 | |
| 71 | If you have two-factor authentication enabled then you'll be prompted to provide an otp token, or may use the `--otp=...` option to specify it on the command line. |
| 72 | |
| 73 | 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`. |
| 74 | |
| 75 | Management of teams and team memberships is done with the `npm team` command. |
| 76 | |
| 77 | ### Configuration |
| 78 | |
| 79 | #### `registry` |
| 80 | |
| 81 | - Default: "https://registry.npmjs.org/" |
| 82 | - Type: URL |
| 83 | |
| 84 | The base URL of the npm registry. |
| 85 | |
| 86 | #### `otp` |
| 87 | |
| 88 | - Default: null |
| 89 | - Type: null or String |
| 90 | |
| 91 | This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with `npm access`. |
| 92 | |
| 93 | 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. |
| 94 | |
| 95 | ### See Also |
| 96 | |
| 97 | - [`libnpmaccess`](https://npm.im/libnpmaccess) |
| 98 | - [npm team](/cli/v7/commands/npm-team) |
| 99 | - [npm publish](/cli/v7/commands/npm-publish) |
| 100 | - [npm config](/cli/v7/commands/npm-config) |
| 101 | - [npm registry](/cli/v7/using-npm/registry) |