Setting Up Yarn with Artifactory
For your Yarn package manager to work with Artifactory, you first need to authenticate Yarn with Artifactory by updating your npm config file, (i.e the
.npmrc file), with the credentials from Artifactory as follows:
For Yarn to work with Artifactory, you first need to set the default npm registry with an Artifactory npm repository using the following command (the example below uses a repository called
Once you have set the default registry, you need to authenticate the npm client to Artifactory.
Run the following command in your npm client. When prompted, provide your Artifactory login credentials:
At this point, the
.npmrcfile will be updated and will display the following confirmation.
You can start using Yarn for installing and publishing packages.
Resolving npm Packages Using Yarn
To install npm packages and adding them as dependencies to your
package.json, run the following Yarn command:
Alternatively, you can run the following command:
Deploying npm Packages Using Yarn
To deploy your package to an Artifactory repository, you can do one of the following:
Add the following to the
And then run the default yarn publish command:
Provide the npm repository you wish to publish to using the yarn publish command as follows:
Working with Scoped Packages
You can set up your project to use scoped packages by directing a scope name to your repository. Add the following line to your project’s
.yarnrc to work with a scoped package. Replace
@jfrog with the relevant scoped package name.
In this example, all Yarn download requests for
@jfrog will be download from Artifactory.
Resolving npm Scoped Packages
To resolve npm scoped packages, run the following command.