How do I use multiple npm registries in Yarn?

kraklin picture kraklin · Nov 28, 2016 · Viewed 14.2k times · Source

I'm trying to setup Yarn 0.17.9 in our environment but I have a problem with our registry. We are currently using two registries, official npmjs and our own registry on internal network (Sinopia).

The problem is that we are using internal tool to pull packages from one or the other with --registry flag via npm install. yarn add doesn't have --registry option and I'm unable to set the custom registry globally with fallback to npmjs. I tried .npmrc but it sets only one registry for npm/yarn in project. .yarnrc doesn't seem to work and is silenced by .npmrc

Is there any way to specify two registries (fallback to second registry if the package is not found in the first one)? Or specify different npm registry per package?

Answer

Andrés Andrade picture Andrés Andrade · Nov 28, 2016

Yarn doesn't have support --registry flag as npm but you can set up your registry in .yarnrc

If your .yarnrc is being ignored it can be copied out of the ~/.yarnrc using:

yarn config set registry http://registry.com/registry//