DEV Community

Henk van den Brink
Henk van den Brink

Posted on • Edited on

Multi NPM registries usage made easy (Azure DevOps)

The problem

I use Azure DevOps for development and have several projects in it.

And I am using the feeds possibility from Azure DevOps.
This means that I need to change the NPMRC each time I switch projects so that it uses the correct registry.

Or you put that in a .npmrc in the repository but then you need to still handle the authentication somehow...

What?

I thought there must be an easier way.

Inspired by the npmrc project I created my own solution, more tailored for Azure DevOps.

But you should still be able to use it as a npmrc switcher, just like the other package but with some added functionality.
Like an interactive list.

To break it down a bit what it does:

It will create an NPMRC with the provided feed-name as registry AND create a PAT that is allowed to pull data from the artifact feed.
And provide options to automatically renew the PAT.

So how to use it?

Easiest

Only one parameter is required

  • feedName (the name of the Artifact feed as created in Azure DevOps)

Then there are a few defaults:

  • name of the NPMRC (defaults to the directory name)

Next to the name of the NPMRC and the feedname we also need the details of the Azure DevOps Organization and Project.

These two values can be retrieved from the repository.url if that is set in the package.json

  • azOrganization (first part of Azure DevOps url)
  • azProject (second part of Azure DevOps url)

Example Azure DevOps url: https://dev.azure.com/henkvandenbrink/kitchensink

azOrganization = henkvandenbrink

azProject = kitchensink

feedName = As specified

Full example:

snmprc create feed-name

This will generate an NPMRC with the specified feed-name as registry, the azure details are retrieved from package.json and current directory name is used as name.

More details options

When you are not able to use the defaults or you just want to have more control, you can specify all the parameters as well.

snpmrc create feed-name henkvandenbrink kitchensink directory-name

This will generate an NPMRC with the specified feed-name as registry, the azure details that are provided and directory-name is used as name.

For all other options, more information and details please go to the simple-aznpmrcs npmjs package where there is a full readme available.

Feature requested are welcome and/or pull requests.

Just another step into automating those manual steps :)

Redis image

Short-term memory for faster
AI agents

AI agents struggle with latency and context switching. Redis fixes it with a fast, in-memory layer for short-term context—plus native support for vectors and semi-structured data to keep real-time workflows on track.

Start building

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Explore this compelling article, highly praised by the collaborative DEV Community. All developers, whether just starting out or already experienced, are invited to share insights and grow our collective expertise.

A quick “thank you” can lift someone’s spirits—drop your kudos in the comments!

On DEV, sharing experiences sparks innovation and strengthens our connections. If this post resonated with you, a brief note of appreciation goes a long way.

Get Started