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 :

//my-private-registry-url/:_auth=<token>
@scope:registry=<http//:my-private-registry-url>

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.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay