Node.js: Node.js runtime selection

How Stackhero selects and manages the Node.js version for your application

👋 Welcome to the Stackhero documentation!

Stackhero provides a ready-to-use Node.js cloud solution designed to help you move faster:

  • Deploy your application to production in seconds with a simple git push. No additional tools or manual configuration required.
  • Use your own domain and benefit from automatic HTTPS certificate setup, ensuring your application is secure without any extra steps.
  • Enjoy automatic backups, one-click updates, and clear, predictable pricing so you can focus on developing features while Stackhero manages the infrastructure.
  • Experience optimal performance and enhanced security thanks to a private, dedicated VM.

Save time and simplify your operations: it only takes a few minutes to try out Stackhero's Node.js cloud hosting solution!

Your Node.js version is defined in your repository, not as a dashboard setting. This approach ensures the runtime version travels with your code, is reviewed alongside your merge requests, and can be reverted by rolling back a commit. There is nothing to update or remember manually before deployment: your code and its runtime are always synchronised.

At each deployment, Stackhero checks for the first matching specification in this order:

  1. image in your stackhero.yml. This pins the exact container image, and all other options are ignored.

    image: node:24-alpine3.21
    
  2. engines.node in your package.json.

    {
      "engines": {
        "node": "24.x"
      }
    }
    
  3. .nvmrc file.

    24
    
  4. .node-version file.

    24.9.0
    

If none of these are found, Stackhero defaults to the current Long Term Support (LTS) release, which is suitable for most projects.

The selected Node.js version and image are displayed at the top of your deployment output, so you always know what is running:

Language        : nodejs 24
Base image      : node:24-slim

Specifying a range such as 24.x, >=24.5.0, or ^24.0.0 ensures you always use the latest available 24.x release. This way, you benefit from every security fix and patch for that series, without any manual intervention.

To lock to a specific release, specify the exact version:

{
  "engines": {
    "node": "24.9.0"
  }
}

.nvmrc can accept aliases like lts/iron or node, but these do not correspond to a specific installable release. In such cases, Stackhero moves on to the next version source in the list. Your deployment output will clearly indicate if this occurs.

A version number is all that is required:

24

When no version is pinned, each deployment uses the current LTS release. This means you automatically receive all major, minor, and security updates as soon as they are published. Your deployment output will inform you when the base image changes:

The base image "node:lts-slim" changed: Node.js 24.9.0 to 26.2.0.

This process is designed to be safe. Your new deployment must start and respond before any traffic is routed to it. If your application is not compatible with a new major version, the previous version continues to serve your users without interruption.

If you prefer to control the upgrade schedule, you can pin your current version series:

image: node:24-slim

The image field accepts any tag from the official Node.js Docker images and uses it exactly as written:

image: node:24-alpine3.21

Be sure to specify the full tag and use an official Node.js image. These two requirements allow Stackhero to reliably manage your deployment, from installing dependencies to starting your application. If you specify an unsupported image, this will be reported before the build begins, and your running application will not be affected.

Alpine tags produce smaller images that start quickly. If your project uses dependencies requiring native code compilation, you may need a Debian-based image. If an installation fails with Alpine, switching to a -slim tag usually resolves the issue.