Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions _posts/2017-05-19-supporting-more-registries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout : post
title : "Private Registry Support"
author : Lukas Spieß
author_url : "https://twitter.com/lumaxis"
date : 2017-05-19 12:00:00
categories : announcements
share_text : "Yarn now supports even more private registries"
---


Today, Yarn already supports a wide variety of different package feeds when fetching and downloading your dependencies. Up until now, there was however a small subset of public and private package feed providers that Yarn could not yet handle very well. One example of these package feed providers that were not yet supported was [Visual Studio Team Services](https://www.visualstudio.com/team-services/) (VSTS).

Let's explain why:

### Registry and package location URL differences

Some registries, such as VSTS, use two slightly different URL structures for the location of the package feed and the location of the actual package archive binary itself.
For example, a private feed's URL would look like this:

```
// Package feed URL
https://$ACCOUNT_NAME.pkgs.visualstudio.com/_packaging/$FEED_NAME/npm/registry
```

but the URLs to fetch the actual tar archives would then be returned by the feed in this format:

```
// Package archive URL
https://$ACCOUNT_NAME.pkgs.visualstudio.com/_packaging/da6e033f-20ad-4ee1-a784-8995dd6836b72/npm/registry/@scope/package-name/-/package-name-0.0.1.tgz
```

As you can see, the archive's URL does not contain the actual feed name anymore but rather a random GUID, followed by the package name and version. This differing layout of the path part of the URL lead to Yarn not recognizing that the two URLs actually both do belong to a request to the same registry and would therefore refuse to download the package.

### Introducing custom host suffixes

Starting with version `0.26.0`, Yarn now understands a new configuration option called `custom-host-suffix`. This allows you to keep the same strict URL validations for most of your package URLs but also selectively loosen that check for a specific registry provider so that Yarn will now match the URLs where the host part ends with the value from this new option.

Simply add `custom-host-suffix` to either your global user-level `.npmrc` or your project's individual `.npmrc` and Yarn will be able to download your packages as desired.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about .yarnrc with an example?

yarn config set custom-host-suffix <url>

Copy link
Contributor Author

@lumaxis lumaxis May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bestander The custom-host-suffix actually does not work with .yarnrc right now, as far as I can tell.
I think npm-registry.js only loads config values from .npmrc: https://github.com/yarnpkg/yarn/blob/master/src/registries/npm-registry.js#L132

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but there us yarn-registry that inherits from npm-registry and reads .yarnrc.
Could you please check if yarnrc works as well?
I expect that it should work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm - doesn't work to add custom-host-suffix to .yarnrc with 0.26.0-20170524.1610. Had to put it into .npmrc and haven't investigated further.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's merge as is and iterate further

In the above example of Visual Studio Team Services, the `.npmrc` should contain an entry like this:

```
custom-host-suffix='pkgs.visualstudio.com'
```

We hope you will find this new option useful and are happy that Yarn can now be used in even more projects!