Why is my Node.js build failing because of no matching Yarn versions?

Issue

Heroku needs to know what version of Yarn to download for any app that is deployed on our platform. The convention is to specify a version requirement in the engines field of package.json.

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "12.10.0",
    "yarn": "1.19.1"
  }
}

However if a version is specified that has no matching version of Yarn then the build prints a warning and fails.

Resolution

Heroku recommends specifying the exact version of Yarn that you are using locally in the engines field. To find your version locally:

$ yarn --version
1.19.1

Use the engines section of your package.json to specify the version of Yarn to use on Heroku:

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "12.10.0",
    "yarn": "1.19.1"
  }
}

You can also specify a semver range by using x as placeholders like: 12.10.x.

You can see a list of all published Yarn versions here: https://nodebin.herokai.com/v1/yarn/linux-x64.txt or by running the command:

yarn info yarn versions

Yarn versions before 0.16.0

Early in Yarn's development there were a number of releases that were not published to npm that Heroku does not support. If you are running an older version of Yarn then we highly recommend upgrading. You will see faster installs and fewer bugs.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support