Publish npm Packages with Yarn

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

Configure Yarn to publish packages to Artifactory by adding the target repository to the package.json file. You can also specify the target repository in the yarn publish command to override the configured target repository.

To publish a package to Artifactory:

  1. Add the following snippet to the package.json file:

    "publishConfig": {
     "registry": "[JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/"
    }

    Where:

    • [JFrogPlatformURL]: The URL of your JPD

    • <REPO_NAME>: The name of the target repository

    For example:

    "publishConfig": {
     "registry": "https://company.jfrog.io/artifactory/api/npm/npm-local/"
    }
  2. Run the following command:

    yarn publish

To publish to a specific repository:

Run the following command:

yarn publish --registry [JFrogPlatformURL]/artifactory/api/npm/<REPO_NAME>/

Where:

  • [JFrogPlatformURL]: The URL of your JPD

  • <REPO_NAME>: The name of the target repository

For example:

yarn publish --registry https://company.jfrog.io/artifactory/api/npm/npm-local/