w3resource

npm-orgs


In our last tutorial, we showed how you can resolve module name disputes. In this tutorial we will show you how to work with Teams and Orgs in npm.

Description

There are three levels of npm org users:

  1. The super admin, the super admin controls billing & adding people to the org.
  2. The team admin, the team admin manages team membership & package access.
  3. The developer, the developer works on packages they are given access to.

Only the Super admin can add users to the org, because it impacts the monthly bill. The super admin uses the website to manage membership. There is a developers team in every org and all users are automatically added to it.

The team admin manages the team creation, team membership, and the package access for teams.

The team admin can only grant package access to teams and not to individuals.

The developer accesses packages based on the team that they are on. The access they granted could be either read-write or read-only.

There are two main commands in npm org, they are:

  1. npm team see npm-team for more details
  2. npm access see npm-access for more details

The Team Admins create teams

  • check to see who you have added to your org
  • npm team ls <org>:developers
  • Each org will be given a developers team automatically, so you will be able to see the whole list of team members in your org. By default, the team has read-write access to all packages, however, you can it with the access comman.
  • You can create a new team using the command below:
  • npm team create <org:team>
  • Then add members to your team:
  • npm team add <org:team><user>

How to publish a package and adjust the package access?

  • Run the following command in the package directory
  • npm init  - -scope=<org>
    so you can scope it for your org and publish.
  • Grant access:
  • npm access grant <read-only|read-write> <org:team> [<package>]
  • Revoke access:
  • npm access revoke <org:team> [<package>]

Monitor the access of your package

  • Run the command below, to see what org packages a team member can access:
  • npm access ls-packages <org> <user>
  • Check the packages that are available to a specific team:
  • npm access ls-packages <org:team>
  • Check the teams that are collaborating on a package:
  • npm access ls-collaborators <pkg>

So, we have shown you how to create and manage teams in an npm org. we also should you how to manage the access of the different team members.

Previous: npm-disputes
Next: npm-registry