Run Yarn commands with Artifactory integration for dependency resolution and build information collection.

This topic covers the following tasks:

When to Use

Use jf yarn if your JavaScript project uses Yarn for dependency management and you want dependencies resolved from Artifactory. For npm-based projects, use jf npm. For pnpm-based projects, use jf pnpm.

Prerequisites

  • Yarn must be installed (1.x or 2+/Berry; Yarn 4.x is currently not supported).
  • Configure a server with jf config add or jf c add.
  • Authentication to Artifactory is required.
  • Run jf yarn-config in the project directory before the first build.

Configuration: jf yarn-config

Generate Yarn configuration for resolving dependencies through Artifactory. Run this once per project before your first build.

To configure Yarn for Artifactory:

Synopsis

jf yarn-config [options]

Aliases: yarnc

Configuration Options

FlagDefaultDescription
--globalfalseApply configuration globally for all projects
--server-id-resolveArtifactory server ID for dependency resolution
--repo-resolveRepository for resolving dependencies

Configuration Examples

View Help

jf yarn-config --help

Non-Interactive Configuration

Configure Yarn with non-interactive flags:

jf yarn-config --server-id-resolve=<server-id> --repo-resolve=<repo-name>

Where:

  • <server-id>: The server ID configured using jf config add
  • <repo-name>: The name of the npm repository in Artifactory

For example:

jf yarn-config --server-id-resolve=my-server --repo-resolve=npm-virtual

Why Run Config First?

You must run jf yarn-config before jf yarn. The config command creates a .jfrog/projects/yarn.yaml file that directs dependency resolution through Artifactory. Without it, jf yarn does not know where to fetch packages.

If you skip this step, you will see the error: no config file was found! Before running the 'jf yarn' command on a project for the first time, the project should be configured with the 'jf yarn-config' command.

Shortcut: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.

Configuration Notes

  • Resolution only: Yarn config supports dependency resolution but not deployment. To publish packages, use jf npm publish.
  • Run once per project: Re-run when changing the resolution repository.
  • Yarn version: Works with Yarn 1.x (Classic) and Yarn 2+ (Berry).

Expected Output

$ jf yarn-config --server-id-resolve=my-server --repo-resolve=npm-virtual
Yarn build configuration saved successfully.

How to Verify

After running, confirm the configuration exists:

cat .jfrog/projects/yarn.yaml

Build: jf yarn

Run Yarn commands with Artifactory integration for dependency resolution and build information collection.

To run Yarn commands with Artifactory integration:

Synopsis

jf yarn [yarn-command] [options]

Aliases: none

Arguments

ArgumentRequiredDescription
yarn-commandNoYarn command and arguments (for example, install, build)

Build Options

FlagDefaultDescription
--build-nameBuild name for build information (requires --build-number)
--build-numberBuild number for build information (requires --build-name)
--projectJFrog Artifactory project key
--moduleOptional module name for build information

Build Examples

Install Dependencies

jf yarn install

Build with Build Information

jf yarn install --build-name=<build-name> --build-number=<build-number>

Where:

  • <build-name>: A name for the build (for example, my-js-app)
  • <build-number>: A number or identifier for the build run (for example, 1)

For example:

jf yarn install --build-name=my-js-app --build-number=1

Important Notes

  • Yarn version: The CLI supports Yarn 1.x (Classic) and Yarn 2+ (Berry). Yarn 4.x is currently not supported. Using jf yarn install with Yarn 4.x will result in an error.
  • Resolution only: Yarn config currently supports dependency resolution from Artifactory. Deployment (publish) is not supported via jf yarn — use jf npm publish or native yarn npm publish instead.
  • Build-info: Use --build-name and --build-number, then publish with jf rt build-publish.

CI/CD Example (GitHub Actions)

# .github/workflows/build.yml
steps:
  - uses: actions/checkout@v4
  - name: Setup JFrog CLI
    uses: jfrog/setup-jfrog-cli@v4
    env:
      JF_URL: ${{ vars.JF_URL }}
      JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
  - name: Configure Yarn
    run: jf yarn-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=npm-virtual
  - name: Install dependencies
    run: jf yarn install --build-name=my-js-app --build-number=${{ github.run_number }}
  - name: Publish build info
    run: jf rt build-publish my-js-app ${{ github.run_number }}

Troubleshooting

SymptomCauseFix
no config file was foundjf yarn-config was not runRun jf yarn-config in the project directory
Error with Yarn 4.xYarn 4.x is not supportedDowngrade to Yarn 3.x or earlier
404 on jf yarn installResolution repository does not exist or name is wrongVerify the repo name matches an existing npm virtual repository in Artifactory
401 / 403 errorsInvalid credentials or insufficient permissionsRe-run jf config add with a valid access token
Cannot publish with jf yarnYarn config is resolution-onlyUse jf npm publish or native yarn npm publish instead

Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG


Related Topics