Set the npm registry used on your computer

The npm registry is the place where npm will look for information about the packages you asked for.

You can think of the registry as a public database where you can check out available packages and download them.

As of today, the default npm public registry is found at https://registry.npmjs.org.

You can check the registry by running the npm config get registry command in your terminal:

$ npm config get registry
https://registry.npmjs.org/

To change the registry, you can run the npm config set registry command, followed by the registry URL:

npm config set registry <registry-url>

Sometimes, you have packages that are not available in the default registry.

For example, installing packages from Bit Cloud requires you to add its registry as a scoped registry.

Here’s how you set a scoped registry:

npm config set '@scope:registry' <registry-url>

When you install a package with a specific @scope, npm will look for the package from the registry you specified above.

One example of public packages that uses a scope is Angular with its @angular scope:

Suppose I have a company named Sebhastian and I have created a private registry for my npm packages at https://node.sebhastian.io

All packages published under my registry will be set to use the @sebhastian owner scope, just like Angular above.

I can set the registry in the config like this:

npm config set '@sebhastian:registry' https://node.sebhastian.io

Whenever I run an install as follows:

npm install @sebhastian/core

Then npm will look into node.sebhastian.io for the package.

Now you’ve learned how to set the npm registry used on your computer. Good work! 👍

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.