DEV Community

Memel Meless
Memel Meless

Posted on

Use a npm package from your private registry

Daily as javascript developer, I use npm. most of the time I use packages from public npm registry. It looks like that in my terminal :
npm install my-public-package
and everything is ok.
What happen to me that week, was simple, another department develop a package and push it on our private internal registry.

the first solution was just doing an install from git with a certain ssh .
like this:
npm install -S "git+ssh://<your project git ssh url>"
we will skip this method

another one is to simply setup your npm config, just the followings steps:
update or create an npm config file :
create an .npmrc file in the root of your home : ~/.npmrc

What do you need :

  • access to the registry : username, password
  • the registry url
  • a base64 encoder tool

Now what will be the content of our recently created .npmrc file ?
We add two things : the private registry url and the authentification token, like this :


The scope is the package or the first part of the package, if your package is @john/doe the scope will be @john, we can just say that the scope is the namespace of the package.

Note that is base64 of 'username:password', username and password of your registry.

after this config you can now install your private npm package as usual doing :
npm install @john/doe

That's all, easy and simple, enjoy with your private registry packages.

Top comments (0)