How to override global yarn registry for particula

2020-05-27 15:31发布

问题:

For most projects I pull packages from the internal server, so it's been added by

yarn config set registry http://custom-packages-server.com

But now in the new project I'd like to use the different (default) one, but use it in that particular project only. As far as I understood if I run the following command inside of new project's directory

yarn config set registry https://registry.yarnpkg.com

it's going to update global registry value for all other projects as well, so they also will be looking for packages in the new place.

So is there a possibility in yarn to override global registry record for a specific project only?

回答1:

Found the way how to achieve that.

It turned out that you can use .yarnrc file inside the project's directory (yeah, pretty much the same like .npmrc). And there you can specify custom config properties which yarn will look into first.

So that's how my .yarnrc file looks now.

registry "https://registry.yarnpkg.com"


回答2:

It is also possible to temporarily override the registry for one yarn command, without having to modify a file:

yarn --registry=https://registry.company.com/