How to change Yarn version in Codemagic builds

Last updated: December 22, 2025

If you need to use a different version of Yarn (either upgrading to a newer version like 3.6.4 or downgrading to an older version), you can change it at runtime using a build script.

Changing Yarn Version

Add the following script to your build configuration to change the Yarn version:

- name: Change Yarn version
  script: |
      corepack disable
      npm uninstall -g yarn
      npm install -g yarn@3.6.4

Replace 3.6.4 with your desired Yarn version number.

Example for Different Versions

To downgrade to an older version like 1.22.19:

- name: Change Yarn version
  script: |
      corepack disable
      npm uninstall -g yarn
      npm install -g yarn@1.22.19

To upgrade to Yarn 3.6.4:

- name: Change Yarn version
  script: |
      corepack disable
      npm uninstall -g yarn
      npm install -g yarn@3.6.4