Publish npm Packages with Yarn

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

You can publish npm packages to Artifactory using either Yarn V2+ (Modern) or Yarn V1 (Classic).

Publish npm Packages with Yarn V2+ (Modern)

You can publish npm packages to Artifactory using Yarn Modern by running the publish command from a package folder.

To publish npm packages to Artifactory with Yarn Modern:

  • Run the following command from the package folder:

    yarn npm publish
Publish npm Packages with Yarn V1 (Classic)

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

    Tip

    You can also publish to a specific repository using the --registry flag to specify the full repository URL after the publish command. For example, yarn publish --registry https://company.jfrog.io/artifactory/api/npm/npm-local/.