npm install from a private registry: the two .npmrc lines

Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan

Every feature on every plan, with unlimited users. 14 days free. No credit card required.

Start free trial

Starting at $99/month billed annually.

Two lines in .npmrc connect npm to a private registry: one routes your scope there, and one gives npm the token for it.

.npmrc
@yourscope:registry=https://your-org.mycloudrepo.io/repositories/your-repo/
//your-org.mycloudrepo.io/repositories/your-repo/:_authToken=${NPM_TOKEN}

Put the file beside your package.json, set NPM_TOKEN, and install as usual:

Terminal
npm install @yourscope/my-package

Your scoped packages come from the private registry. Every other package still comes from the public npm registry. The examples use a CloudRepo npm repository: swap in your own organization, repository and scope.

What each line does

@yourscope:registry= sends every package in your scope to the private registry. npm can route a scope to a second registry, not an unscoped package, so give your private packages a scope.

//your-org.mycloudrepo.io/repositories/your-repo/:_authToken= gives npm the token for that registry. npm sends the token only to the registry this line names, and sends it alone, with no username.

${NPM_TOKEN} expands from the environment variable of that name, so you can commit the file without putting the token in it.

Two details trip people up: keep the trailing / on both lines, and make the second line match the registry URL without https:.

CloudRepo, JFrog Artifactory and Sonatype Nexus, side by side

Compare CloudRepo with
CloudRepo, JFrog Artifactory and Sonatype Nexus, side by side
Question CloudRepo Essentials JFrog Artifactory Cloud Pro Sonatype Nexus Pro Cloud
Included each month 10 GB storage and 250 GB transfer 25 GB, then $1.25/GB storage and transfer counted together [1] 25 GB, then $1.10/GB of consumption [2]
Users Unlimited, on every plan Typically up to 50 users how JFrog sizes Pro [1] New contracts are priced by consumption [3]
Support Human support, on every plan Community support: public documentation, a knowledge base and Stack Overflow [4] Pro lists enterprise support, SLA and migration services as available [2]

Every feature on every plan

Start free trial Or compare your Sonatype or JFrog quote with ours

14 days free. No credit card required.

Starting at $99/month billed annually.

Sources (4): each vendor's own pages, read 2026-10-06 to 2026-10-21. Prices as each vendor listed them on the date shown.
  1. JFrog pricing, read (archived)
  2. Sonatype pricing, read (archived)
  3. Sonatype pricing, read
  4. JFrog pricing, read (archived) Community Support - Available for Free solutions and Pro subscriptions - JFrog maintains public documentation, knowledge base, and engages in conversations on Stack Overflow.

Why not registry=?

A registry= line sends every package to that one registry, including public packages. A hosted repository holds only what you published to it, so every public package returns 404. For a hosted repository, keep the scope line.

To install public packages through CloudRepo as well, create an npm proxy repository of the public npm registry, and use that as the registry.

Get a token

In CI, create a repository token with access to the repository. A token with Download packages access is enough to install. Save it in your CI’s secret store as NPM_TOKEN. Repository tokens shows how.

On your own machine, npm login signs you in through your browser and saves a token for you, so you have nothing to copy. Your project’s .npmrc then needs only the scope line. npm login shows the steps.

Check the token

Terminal
npm whoami --registry=https://your-org.mycloudrepo.io/repositories/your-repo/

npm prints the email address of the account that created the token. If the token is mistyped, expired or revoked, it fails here before any install runs.

This matches the setup in the CloudRepo docs, and we run it with the real npm.

When npm returns 401, 403 or 404

  • 401. npm prints Your token wasn't accepted. Run npm login or check the token in your .npmrc. The token is mistyped, expired, revoked or from another organization. Check its status on the Repository Tokens page in the admin portal.
  • 403 Forbidden. The token does not have access to this repository. A token only accesses the repositories ticked when it was created, so use one that includes it.
  • 404 for your own package. With a valid token, npm is checking the public registry: the @yourscope:registry= line is missing or names another scope. Next, verify that the token line’s prefix matches the registry URL exactly.
  • 404 through a proxy repository. A proxy repository that the token cannot access returns 404, not 403. Check that the token includes the proxy.

More in Install npm packages from CloudRepo.

Every feature on every plan, with unlimited users

14 days free. No credit card required.

Starting at $99/month billed annually.

Chris Shellenbarger, founder of CloudRepo

Founder-run since 2016, with no venture capital. A real person answers within one business day. Usually it's me.

Chris, founder of CloudRepo