Table of Contents [expand]
Last updated February 26, 2026
Some sbt plugins require a JavaScript engine for asset processing. For example, sbt-rjs performs RequireJS optimization and sbt-uglify performs UglifyJS minification. These plugins use sbt-js-engine to run JavaScript, which defaults to Trireme, a JVM-based JavaScript runtime.
Trireme works for small operations, but its performance degrades with large numbers of files. Using a native Node.js engine significantly improves build times. This guide shows how to configure your Play or Scala project to use Node.js for JavaScript processing on Heroku.
Add the Node.js Buildpack
To make Node.js available during your sbt build, add the Node.js buildpack before the Scala buildpack:
$ heroku buildpacks:clear --app example-app
$ heroku buildpacks:add heroku/nodejs --app example-app
$ heroku buildpacks:add heroku/scala --app example-app
Verify the order:
$ heroku buildpacks --app example-app
=== example-app Buildpacks
1. heroku/nodejs
2. heroku/scala
The Node.js buildpack must run first so that node is on the PATH when sbt executes.
Add a package.json
The Node.js buildpack requires a package.json file in your project root. Create a minimal one specifying a Node.js version:
{
"engines": {
"node": "24.x"
}
}
See Heroku Node.js Support for available Node.js versions.
Add the file to your repository:
$ git add package.json
$ git commit -m "Add package.json for Node.js buildpack"
Configure sbt-js-engine
By default, sbt-js-engine uses AutoDetect, which prefers Node.js if it’s available on the PATH. Since the Node.js buildpack installs node before sbt runs, sbt-js-engine picks it up automatically.
If you need to force Node.js explicitly, add the following to your build.sbt:
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
Or set it via the SBT_OPTS config var:
$ heroku config:set SBT_OPTS="-Dsbt.jse.engineType=Node" --app example-app
Deploy
Deploy your changes:
$ git push heroku main
During the build, the Node.js buildpack installs Node.js first, then the Scala buildpack runs sbt which uses the Node.js engine for JavaScript processing.
For more information, see the sbt-js-engine documentation and Heroku Scala Support.