jf yarn
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 addorjf c add. - Authentication to Artifactory is required.
- Run
jf yarn-configin the project directory before the first build.
Configuration: jf yarn-config
jf yarn-configGenerate 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
| Flag | Default | Description |
|---|---|---|
--global | false | Apply configuration globally for all projects |
--server-id-resolve | — | Artifactory server ID for dependency resolution |
--repo-resolve | — | Repository for resolving dependencies |
Configuration Examples
View Help
jf yarn-config --helpNon-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-virtualWhy 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.yamlBuild: jf yarn
jf yarnRun 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
| Argument | Required | Description |
|---|---|---|
yarn-command | No | Yarn command and arguments (for example, install, build) |
Build Options
| Flag | Default | Description |
|---|---|---|
--build-name | — | Build name for build information (requires --build-number) |
--build-number | — | Build number for build information (requires --build-name) |
--project | — | JFrog Artifactory project key |
--module | — | Optional module name for build information |
Build Examples
Install Dependencies
jf yarn installBuild 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=1Important Notes
- Yarn version: The CLI supports Yarn 1.x (Classic) and Yarn 2+ (Berry). Yarn 4.x is currently not supported. Using
jf yarn installwith 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— usejf npm publishor nativeyarn npm publishinstead. - Build-info: Use
--build-nameand--build-number, then publish withjf 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
| Symptom | Cause | Fix |
|---|---|---|
no config file was found | jf yarn-config was not run | Run jf yarn-config in the project directory |
| Error with Yarn 4.x | Yarn 4.x is not supported | Downgrade to Yarn 3.x or earlier |
404 on jf yarn install | Resolution repository does not exist or name is wrong | Verify the repo name matches an existing npm virtual repository in Artifactory |
| 401 / 403 errors | Invalid credentials or insufficient permissions | Re-run jf config add with a valid access token |
Cannot publish with jf yarn | Yarn config is resolution-only | Use jf npm publish or native yarn npm publish instead |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Related Topics
- Build Tools Overview — Capabilities matrix and tool reference
- Native Mode — Supported packages with Native Mode
Updated 8 days ago
