You can use the Yarn client to install and publish npm packages. You can also set up your project to use scoped packages by directing a scope name to your repository. For your Yarn package manager to work with Artifactory, you need to authenticate Yarn with Artifactory by updating your .npmrc file with your Artifactory credentials.
Note
Artifactory is tested with Yarn Classic and is confirmed to support up to version 1.22.4. Artifactory does not yet support Yarn Modern (v2+).
To configure the .npmrc file for use with Yarn and Artifactory:
Run the following command to set an Artifactory repository as the default npm registry:
npm config set registry [JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/Where:
[JFrogPlatformURL]: The URL of your JPD<REPO_NAME>: The name of the target repository
For example:
npm config set registry https://company.jfrog.io/artifactory/api/npm/npm-virtual/Run the following command to authenticate to Artifactory, and enter your credentials when prompted:
npm login
To set up scoped repositories for Yarn:
Add the following line to your project’s .yarnrc:
"@<SCOPE>:registry" "[JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/"Where:
<SCOPE>: The target scope[JFrogPlatformURL]: The URL of your JDP<REPO_NAME>: The name of the target repository
For example:
"@company:registry" "https://company.jfrog.io/artifactory/api/npm/npm-virtual/"After running this command, all yarn add requests for the specified scope download from the Artifactory repository.
Next steps: