When you select the option to Use Buildpacks to set up container image, if you do not specify a version in your application’s code, the Buildpack will use the latest available version. If you want to use a different language version for your application, you’ll need to set the version in your application’s files.

The method for setting the version varies by language. Below we’ve included examples for currently supported languages.

Go

To specify your Go version, include the following in your application’s go.mod file:

// +heroku goVersion go1.11
go 1.21.1

Java

To specify your Java version, include the following in your application’s system.properties file:

java.runtime.version=11

Node.js

To specify your Node.js and npm versions, include the following in your application’s package.json file:

"engines": {
  "node": "^16.14.0",
  "npm": "^8.3.1"
}

React

If you’re using React and want to specify your React version, replace or add the React version in the dependencies of your package.json file:

"react": "^17.0.2"

To also set the Node.js and npm versions in your React application, include the following in your application’s package.json file:

"engines": {
  "node": "^16.14.0",
  "npm": "^8.3.1"
}

PHP

To specify your PHP version, include the following in your application’s composer.json file:

{
  "require": {
    "php": "~8.1.0"
  }
}

Python

To specify your Python version, include the following in your application’s runtime.txt file:

python-3.10.13

You can also specify module versions within the requirements.txt file:

Django==4.1
virtualenv==20.18.0

Ruby

To specify your Ruby version, include the following in your Gemfile:

ruby "3.0.6"

Scala

To specify your Scala version, include the following in your application’s build.sbt file:

scalaVersion := "3.2.2"

Related Documentation