Skip to the content.

TIL - Config .yarnrc to ensure the registry to use

If npm has configured its own registry in .npmrc, yarn install will use it instead of the yarn configured one. Set expected registry in .yarnrc under current project to enforce.

The situation:

  • yarn v1.16.0
  • npm 6.9.0
  • registry=https://registry.npm.taobao.org in ~/.nmprc

What’s the result:

~$ yarn config list
yarn config v1.16.0
info yarn config
{ 'version-tag-prefix':
  ...
  ...
  registry:
   'https://registry.yarnpkg.com',
  'strict-ssl':
   true,
  'user-agent':
   'yarn/1.16.0 npm/? node/v10.16.0 darwin x64',
  lastUpdateCheck:
   1559793259358 }
info npm config
{ registry:
   'https://registry.npm.taobao.org' }
✨  Done in 0.03s.

And run yarn install will result in updated/newly installed pkg from npm’s registry (in yarn.lock).

To use yarn’s registry forcedly by add --registry "https://registry.yarnpkg.com" to .yarnrc in current project’s root dir.

References:

Running a yarn command with yarn sets registry to https://registry.yarnpkg.com

END

Written on June 6, 2019