Rails/Dockerfile: wrong node version

Hi folks,

I’m porting a repo from Heroku. I have a node version set in my package.json as 18.5.0, this seemingly get installed and used correctly at the beginning of my deploy. I also have a .node-version file with the same version within it.

Later on in the deploy, a different version of node is installed (node-v16.13.1-linux-x64) which subsequently breaks the deployment.

Can anyone help me figure out this issue?


Nov 3 10:52:23 PM #9 284.9 -----> Installing node-v16.13.1-linux-x64
Nov 3 10:52:26 PM #9 287.6 -----> Installing yarn-v1.22.17
Nov 3 10:52:27 PM #9 288.6 -----> Detecting rake tasks
Nov 3 10:52:36 PM #9 297.3 -----> Preparing app for Rails asset pipeline
Nov 3 10:52:36 PM #9 297.3 Running: rake assets:precompile
Nov 3 10:52:42 PM #9 303.4 I, [2022-11-03T22:52:41.256293 #5093] INFO – honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.12.2 framework=rails level=1 pid=5093
Nov 3 10:52:42 PM #9 303.8 yarn install v1.22.17
Nov 3 10:52:42 PM #9 304.0 [1/5] Validating package.json…
Nov 3 10:52:43 PM #9 304.0 error redacted@0.1.0: The engine “node” is incompatible with this module. Expected version “~18.5.0”. Got “16.13.1”
Nov 3 10:52:43 PM #9 304.0 error Found incompatible module.
Nov 3 10:52:43 PM #9 304.0 info Visit yarn install | Yarn for documentation about this command.
Nov 3 10:52:43 PM #9 304.6 rake aborted!
Nov 3 10:52:43 PM #9 304.6 cssbundling-rails: Command css:build failed, ensure yarn is installed and yarn build:css runs without errors
Nov 3 10:52:43 PM #9 304.6 /app/vendor/bundle/ruby/3.1.0/gems/cssbundling-rails-1.1.1/lib/tasks/cssbundling/build.rake:5:in `block (2 levels) in ’
Nov 3 10:52:43 PM #9 304.6 Tasks: TOP => assets:precompile => css:build
Nov 3 10:52:43 PM #9 304.6 (See full trace by running task with --trace)

Hi Rikki,

Thanks for reaching out.

It looks like you’ve used the migration tool here, and the buildpack from Heroku isn’t picking up your Node config. You’d need to include the Heroku Node buildpack to define a specific Node version. If you’re using just the Ruby buildpack, it comes 16.13.1, as shown in the logs you shared (and noted in their docs here).

If your project only requires Ruby & Node you may be better off using a Native Environment to avoid some of the Docker-running-Heroku-buildpacks complications. You’d use the Ruby environment, and Node would also be available.

You’d set a Build Command & Start Command to get the app up and running. The Build Command could be a script, like the example in our Rails guide. The Start Command would be the same as the web: command in your Procfile.

Please let us know if we can assist any further.


Thanks, Alan!

Looking deeper into this, I think I reverted to the Docker approach because of a couple of extra buildpacks I was using. Namely, because Heroku doesn’t have ffmpeg etc. installed. A quick Google looks to show that Render has ffmpeg installed by default. I’ll double check my other dependencies like vips and see if everything works properly on the native approach.

Cheers again,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.