Use a scoped registry with Yarn

When working with private packages we have a few options to use as our registry

  • npm registry
  • GitHub registry
  • Custom registry (e.g. Verdaccio)

If we decide to use the npm registry, and pay for it, we can continue using Yarn and npm without changes. And what if we use another one? And if we want to keep using the npm registry for non-scoped packages?

Enter .yarnrc, create this file inside the project root and write this:

"@company:registry" ""

Now every time you install a package with the @company scope (e.g. @company/design-system) Yarn will use the GitHub registry to download it instead of the public npm registry.

You can use any scope and any URL as a registry, if you setup your own Verdaccio registry under you can add:

"@company:registry" ""

And the best thing is that you can have more than one:

"@frontend:registry" ""
"@backend:registry" ""