Install private packages with Yarn

Once you have signed up for a Gemfury account and uploaded some npm packages, you can install them with Yarn.

Setting up your global configuration

To start using your private registry with Yarn, you will need to update your npm config and authenticate using your personal Gemfury credentials:

npm config set registry https://npm.fury.io/USERNAME/
npm config set always-auth true
npm login

It is important to include a trailing slash in the registry URL, otherwise yarn may have trouble connecting to your Gemfury registry.

This will update your personal ~/.npmrc file with the following:

always-auth=true
registry=https://npm.fury.io/USERNAME/
//npm.fury.io/USERNAME/:_authToken=SECRET-TOKEN

Now you can specify Gemfury packages in your project’s package.json dependencies and run yarn install

Using Gemfury along with the public registry

The npm.fury.io repository only enables access to your Gemfury packages, however, we also offer a blended-index endpoint to allow you to install packages from both your Gemfury account and from the public index:

https://npm-proxy.fury.io/USERNAME/

You can activate the blended repo by replacing npm.fury.io with npm-proxy.fury.io in either the command-line or directly in .npmrc config as described above:

npm config set registry https://npm-proxy.fury.io/USERNAME/
npm config set always-auth true
npm login

It is important to include a trailing slash in the registry URL, otherwise yarn may have trouble connecting to your Gemfury registry.

When you run Yarn commands, the blended-index proxy will first look for a named package in your Gemfury account, and if it is not found, it will fall back in the public index.

Per-project configuration

If your project relies on private packages, we recommend committing a project-specific configuration to ensure consistent installs. Just commit a .yarnrc file to the root directory of your project:

# PROJECT_DIR/.yarnrc
registry "https://npm.fury.io/USERNAME/"

Each collaborator can subsequently authenticate using their Personal credentials before running yarn commands in the project directory:

npm config set always-auth true
npm login --registry=https://npm.fury.io/USERNAME/

This method can be used with either npm.fury.io or npm-proxy.fury.io endpoint.

Working with scoped packages

You can also set up your project to use scoped packages by directing a scope name to your Gemfury account. Adding this line to your project’s .yarnrc file will direct all @myscope packages to be installed from Gemfury:

# PROJECT_DIR/.yarnrc
"@myscope:registry" "https://npm.fury.io/USERNAME/"

Although the scope name needs to match the scope of your named dependencies in package.json, it does not necessarily have to match your Gemfury username. Thus you can have multiple scopes per account.

You can subsequently authenticate using your Personal credentials before running yarn commands in the project directory. Be sure to include the trailing slash or the command will fail to authenticate:

npm login --registry="https://npm.fury.io/USERNAME/"

This command will insert the following line into your ~/.npmrc:

//npm.fury.io/USERNAME/:_authToken=SECRET-TOKEN