Specifying the node version to use for an app

Hi there
I’m trying to port my Nuxt app from Heroku to Fly.io and running into the following error when I run ‘flyctl launch’:
The engine "node" is incompatible with this module. Expected version "16.18". Got "18.13.0"
It seems that I need to explicitly specify the node version to use for this app. Where can I do that?

FWIW, I already have a version specified in the package.json this way:

  "engines": {
    "node": "16.18"


I’m guessing that since you are porting from Heroku, it would be using a buildpack. The default would logically be the LTS version of Node, which right now is indeed 18.13.

I had a quick look and Heroku has a command to override that (scroll down in heroku/heroku-buildpack-nodejs - Buildpacks - Heroku Elements) … however I’m not sure if there is a Fly equivalent. Might be worth looking in your fly.toml file (if you have one) to see if there is any version number in there. If so, may be as simple as changing that number (e.g 18 to 16).

Assuming not, the other way to deploy to Fly is by using a Dockerfile (and sibling .dockerignore to tell it what not to include). I believe if you run fly launch from a folder (without a fly.toml in) it will treat it as a new app, spot it is Node, and make a Dockerfile for you. Armed with a Dockerfile, you can then customise it to do whatever you want. Often the first line will specify the node version. For example this is a very basic hello-world node app:

It’s far from optimised, but see this very first line of the Dockerfile tells the builder to work with node 18. You’d simply change that number to whatever version you needed installed. And make any other changes Nuxt needs (dependencies etc). Fly would see that on fly deploy and run the commands within it:

1 Like