Search code examples
npmazure-devopsazure-artifacts

Why does my project require multiple npmrc registries when the artifact already includes them as upstream sources?


I have two mono repositories that use Node/NPM/Lerna to manager and distribute multiple packages.

Project X includes .npmrc file with a single registry. This registry is for a private Azure Feed that includes three upstream sources. Named ( A, B, C )

  1. A - Public NPMJS
  2. B - Private Package
  3. C - Private Package

Project Y requires .npmrc file with two namespaced registries.

  1. The first is the same that Project X uses.
  2. The second *seems* to be required and @register's the Azure Feed for B.

My question is if my .npmrc file is registering a package that contains three upstream feeds, why do I additionally have to register one of these upstream feeds in my .npmrc file (B)?

It was my understanding from documentation that Upstream Feeds are an alternative approach to registering multiple namespaced packages in your .npmrc file.

I'm clearly missing something. Please assist. Thanks


Solution

  • You are correct that Project X is using the set-up that we recommend, which is a single Azure Artifacts feed in your .npmrc's registry= line that upstreams to any other feeds you need.

    However, Project Y may have chosen to use scopes to instead only use limited packages from Azure Artifacts while pulling most packages directly from npmjs.com. We generally don't recommend this, but it's a valid way to work. Note that in this configuration, Project Y does not get to take advantage of the benefits of upstream sources (like a saved copy of anything you use from npmjs.com, in case it's later deleted).

    If you want to migrate to the recommended configuration, try ensuring that Project Y's .npmrc has a single registry= line:

    registry=https://dev.azure.com/.../ProjectXFeedWithUpstreams/...

    and see if it still builds (delete or rename node_modules when you run npm install).