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": "6.11.1",
    "yarn": "0.27.5"
  }
}

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
0.27.5

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": "6.11.1",
    "yarn": "0.27.5"
  }
}

You can also specify a semver range by using x as placeholders like: 0.27.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.