Why is my Node.js build failing because of an invalid semver requirement?

Issue

Heroku needs to know what version of Node.js 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": "13.1.0"
  }
}

However if the version requirement does not conform to a semver range then Heroku cannot determine what version to use to run your application.

Resolution

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

$ node --version
v13.1.0
$ npm --version         
6.12.1
$ yarn --version
1.19.1

Use the engines section of your package.json to specify the version of those binaries to use on Heroku.

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

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

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