Rails precompile fails due to missing ExecJS runtime

I used the Turboku launcher for my Heroku-hosted Rails app and it worked great - my app deployed and it works! However, I cannot deploy anymore. I get the following during build:

 > [stage-3 7/7] RUN bin/rails fly:build:
#20 3.527 rails aborted!
#20 3.527 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
#20 3.527 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
#20 3.527 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
#20 3.527 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<main>'

This is telling me that ExecJS is trying to precompile my assets and cannot find a runtime to do that. Question 1: why did this work when using Turboku but does not anymore? Question 2: how can I fix this?

1 Like

Iā€™m currently migrating old Rails apps from Heroku to fly and find a solution.

You can add nodejs to DEPLOY_PACKAGES within the Dockerfile to fix the missing ExecJS runtime.