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

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
v6.11.1
$ npm --version         
5.2.0
$ yarn --version
0.27.5

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

You can also specify a semver range by using x as placeholders like: 8.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
Terms of Service Privacy Cookies © 2018 Salesforce.com