Does Rails 7.1 needs nodejs for using bootstrap?

Hi,

I am finding it hard to understand if latest Rails 7.1 really require nodejs to be installed if I plan to use bootstrap? I tried installing the bootstrap in Gemfile and then after “bundle install” if I restart the rails server, I immediately get the below errror. If I install nodejs, all works well. Do I really need to install nodejs if I need to use bootstrap in Rails 7?

/home/test/.rvm/gems/ruby-3.3.3/gems/execjs-2.9.1/lib/execjs/runtimes.rb:68:in autodetect’: Could not find a JavaScript runtime. See GitHub - rails/execjs: Run JavaScript code from Ruby for a list of available runtimes. (ExecJS::RuntimeUnavailable)`

i think rails needs node as of right now.

Rails 7.0.0 version has the nodejs requirement mentioned in the docs, however there is NO mention of using nodejs as a pre-requisite in the current latest version. The docs aren’t clear to understand.

IF you are using Sprockets, then you will need some kind of JS runtime (Node is one option, there are others) in order to run the fingerprinting of assets. If you use Propshaft, then that is not necessary. Furthermore, if you are using either Sprockets or Propshaft and you are also using Import Maps (and thus not using CSSBundling or Webpacker or similar to compile JS assets), then you can similarly ignore any JS runtime requirement. But you need a JS runtime of some kind to handle precompiling assets. This doesn’t mean that you need Node to run your app, just to get the app ready to run without it. It’s very much like having Ruby installed.

Walter

The simplest way is to include bootstrap statically (no gem, just download and use the prebuilt css/js) unless you really need to build it from sass.