Skip to main content

Team NPM accounts

What team NPM accounts are and how to use them

Written by Zoli Andras

What is the purpose of Team NPM accounts?

Team NPM accounts replace individual developer accounts when it comes to NPM package installation. Each team can have a single NPM user set up, that is shared amongst the developers. Projects then can be configured to use the team NPM credentials to install Mobiscroll.

What does it solve?

Since NPM access is based on user credentials, whenever a user changes their password, a project that was set up by them will lose access and will need to be set up again.

Also when a license is reassigned to another developer - that can happen for various reasons (developer leaving a team or working on something else) - they lose the access until Mobiscroll is reinstalled with the new credentials.

When using CI/CD environments, things can get even more problematic. Even if a developer changes their password, the CI/CD pipeline will break and won't be able run an npm update until a new login token is pushed in.

How to update a project to use a team NPM account instead of an individual user account?

  1. Set up NPM access for your team

    This can be done from the Licenses page by any developer.

    1. First, click the "Set up NPM access" button above the assigned developers list

      Image showing the Set up NPM access button on the licenses page
    2. Enter a username

    3. Generate a secret for your company

    4. Save the credentials

      Image showing the steps to take to set up team NPM access. Username field, generate a secret and click the save button.

  2. Update the credentials in the CLI and reinstall Mobiscroll

    Run a login command in the project's root folder.

    mobiscroll login

    The command prints a sign-in link and a code; press Enter to open the link in your browser. On the approve page, choose the team NPM user under "Sign in as" instead of your own account, then approve. To type the team NPM user's name and secret in the terminal instead, run mobiscroll login --password.

    Note: The browser sign-in needs Mobiscroll CLI 2.0.0 or newer. To update it, run npm install -g @mobiscroll/cli.

  3. Commit and push the login token into your repository

    The login command will create or update a file called .npmrc or .yarnrc.yml (for yarn users). This file contains the authorization token. Commit and push it into your repository so that other developers and CI/CD environments are granted access to the packages.
    If you commit the .npmrc, the package installs for other team members and in CI/CD out of the box, but anyone who can read the repository can use the token. For other setups, such as the user-level ~/.npmrc or an environment variable, see Using the npm auth token securely (https://mobiscroll.com/docs/react/guides/npm-auth-token).

Updating team NPM account credentials

Updating the credentials can be done from the Licenses page by any developer that is part of the team. After you change the secret, tokens created before Mobiscroll CLI 2.0.0 (they contain the secret) stop working. The tokens from the browser sign-in are cancelled too, because "Also cancel the existing team tokens from the CLI sign-in" is ticked by default when you save; untick it to keep them working and change only the secret. You can see and cancel the team's tokens on the Access Tokens page (https://mobiscroll.com/account/tokens).

  1. First, click the "Change access" button

    Image showing the Change access button on the licenses page

  2. Generate a new secret by clicking the "Generate secret" button

  3. Optionally change the username

  4. Hit the save button to update the credentials

    Image showing the steps to take to change the team NPM access. Generate a new secret by clicking the generate secret button and optionally changing the username field as well. Then clicking the save button to update the credentials.

To update the authorization tokens, the mobiscroll login command needs to be run in the project's root folder:

mobiscroll login

Approve the sign-in in your browser and choose the team NPM user under "Sign in as" on the approve page. To type the updated user and secret in the terminal instead, run mobiscroll login --password.

The login command will update the authorization token in a file called .npmrc or .yarnrc.yml (if you are using yarn instead of npm). This change has to be committed and pushed into the repository.

Did this answer your question?