Running a recent Node version on DigitalOcean App platform

By

Learn how to pin Node.js 22 or 24 on DigitalOcean App Platform, and when to upgrade from the legacy Node buildpack to the current Heroku Node.js buildpack.

~~~

To run a recent Node.js version on DigitalOcean App Platform, pin the version in the engines field of package.json. On older apps you may also need to leave the legacy Node buildpack behind. (That’s my DigitalOcean referral link.)

New App Platform apps use the Heroku Node.js buildpack (version 342 as of September 2026). When you don’t set engines, it installs Node.js 22.x. It also supports Node 24, the Active LTS line, so that’s what I’d pick for a new app.

Set the Node version

Put the version you want in package.json:

{
  "engines": {
    "node": "24.x"
  }
}

22.x is also fine if you want to match the platform default. The buildpack reads engines and installs the newest release of that major during the build.

Set it even if you’d get 22 anyway. Without engines, the default moves when DigitalOcean moves it (it went from 20 to 22, and 24 will come), and one day your app builds on a Node you never tested.

New buildpack vs legacy buildpack

Apps created after 17 September 2024 already use the new Node.js buildpack.

If your app is older, open the app in the control panel and check the Build Phase section. If the buildpack listed is Node.js v0.4.1, you are on the legacy buildpack. DigitalOcean recommends upgrading, and the legacy one is what kept my app on Node 16 back in 2023.

To switch, edit the App Spec and add:

features:
  - new-nodejs-buildpack=true

Saving the spec triggers a redeploy on the new buildpack. DigitalOcean documents this in their Node.js buildpack migration guide.

One gotcha on the new buildpack: it runs npm run build (or yarn build / pnpm build) by default, and any build_command from the App Spec runs after that. If you had a custom build_command, move that logic into the build script in package.json and remove it from the App Spec, or your build runs twice.

Ubuntu 22 stack (older tip)

When I first wrote this post, at the end of 2023, App Platform apps defaulted to Node 16.x, and the fix was forcing the Ubuntu 22 stack in the App Spec:

features:
  - buildpack-stack=ubuntu-22

Then I set engines to 21.x. For whatever reason, asking for the LTS 20.x didn’t work for me on that setup, so I used 21.

Ubuntu 22 is now the normal App Platform stack, and the buildpack supports the LTS lines, so you don’t need any of this on a current app. Keep the stack line only if an old app is still stuck on an older stack.

How do you know it worked?

Check the build logs of the next deployment. The buildpack prints the Node version it installs.

You can also log it from the app itself:

console.log(process.version) //v24.15.0

If you still get an old Node

Check that engines.node in package.json says what you expect (22.x or 24.x), and that the app is on the new Node.js buildpack, not the legacy one.

Then open the App Spec again and make sure the features entries sit at the top level of the YAML. A wrong indentation makes the setting silently disappear when you save.

Tagged: Services · All topics

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about services: