junlin
junlin

Reputation: 2045

How to use different yarn registry regardless of registry in the yarn.lock file?

My yarn.lock file looks like:

[email protected]:
  version: "x.x.x"
  resolved: "http://registry.yarnpkg.com/package/-/xxxx"

But the CI is in intranet and the registry is http://99.12.xx.xx/xxx

How to use intranet registry in CI build regardless of the internet registry in the yarn.lock file?

Upvotes: 8

Views: 8616

Answers (2)

Roman Maksimov
Roman Maksimov

Reputation: 1635

To save actual dependencies you can remove a resolved directive from the yarn.lock file, set your repository and renew yarn.lock by yarn install

sed -i -e "/resolved:* .*$/d" yarn.lock
yarn config set registry <YOUR_REGISTRY>
yarn install

To prevent yarn.lock break by other developer you can also file a your registry setting into .yarnrc

.yarnrc

registry "<YOUR_REGISTRY>"

Upvotes: 5

osmarpixuri
osmarpixuri

Reputation: 171

This is an old issue on yarn's github repository as you can see here

I solved this issue by running a sed command to substitute the registry link before installing packages:

sed -i -e "s#https://registry.yarnpkg.com/#{YOUR_CI_REGISTRY}#g" yarn.lock

hope that helps.

Upvotes: 17

Related Questions