ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.
Questions tagged [execjs]
98 questions
3
votes
3 answers
"Could not find a JavaScript runtime". How do I install one?
I am unable to start a rails server. Apparently I don't have a JavaScript runtime.
$ rails s
c:/Ruby22/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to…

Zak Janzi
- 43
- 3
- 8
3
votes
2 answers
Running jQuery in Ruby
I want to run jQuery in a Ruby application and use it to manipulate an HTML string. (Yes, I know there are other Ruby libraries that can handle that task, but I have a good reason for using jQuery in this case.) Is this possible? I know that I can…

Ajedi32
- 45,670
- 22
- 127
- 172
2
votes
1 answer
Testing ajax from therubyracer (or execjs)?
I want to test javascript code from a ruby context. Specifically, I want to setup my database with ruby, query it with my javascript model, and confirm my javascript state from ruby. I want to do this without mocking.
I've tried simply loading my…

Dane O'Connor
- 75,180
- 37
- 119
- 173
2
votes
1 answer
Ruby Rails Execjs : How to create external runtime utilitizing bun.sh?
I would like to run javascript code in my ruby program. But it is very slow, so I would try to use bun.sh instead of nodejs as a runtime in execjs.
How can I achieve that ?
I tried this:
require 'execjs'
require…

Jan Černý
- 1,268
- 2
- 17
- 31
2
votes
1 answer
Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
I have other rails app on this server working fine...
I have nodejs install on my serveur
I have gem 'therubyracer', platforms: :ruby in gemfile,
I try bundle install,
I try config.assets.js_compressor = Uglifier.new(harmony: true) in prod conf
but…

Matrix
- 3,458
- 6
- 40
- 76
2
votes
2 answers
Rails 3.1 and Heroku - Still not working even with 'therubyracer-heroku'
I cannot deploy my Rails 3.1rc4 app to Heroku even though I added this to my Gemfile: gem 'therubyracer-heroku', '0.8.1.pre3', :group => :production
I can't figure out what the problem is, here is the log: gist

LanguagesNamedAfterCofee
- 5,782
- 7
- 45
- 72
2
votes
1 answer
Using nested folders with react-rails prerender
I'm trying to set up react-rails for my app (https://github.com/reactjs/react-rails).
I had no problem getting it to set up initially, but I'm anticipating a lot of different individual components so I want to organize my /javascript/components…

Almaron
- 4,127
- 6
- 26
- 48
2
votes
2 answers
uninitialized constant ExecJS::Runtimes::RubyRacerRuntime
In my existing project I changed
gem "twitter-bootstrap-rails"
to
gem 'bootstrap', '~> 4.1.3'
in my Gemfile. I'm getting now
uninitialized constant ExecJS::Runtimes::RubyRacerRuntime
on line: <%= stylesheet_link_tag "application", :media => "all"…

David
- 825
- 10
- 33
2
votes
1 answer
Why ExecJS constantly uses 100% CPU?
I'm using Ruby 2.2.4 and Rails 4.2.5 and Capistrano to deploy, but after my latest commit suddenly server always uses 100% CPU. I used htop and saw command nodejs tmp/execjs use all the CPU.
CPU usage
Can anyone explain this and tell me a solution…

lufutu
- 33
- 4
2
votes
1 answer
How to load pure JS file using ruby gem commonjs?
Simple question: how to load pure .js file from ruby?
My current strategy is to load a .js file from within ruby is to use the commonjs gem. I recognize that the instructions are to load the js directory and then require the file. Unfortunately, I…

binarymason
- 1,351
- 1
- 14
- 31
2
votes
1 answer
Passing arguments with ExecJS
I need to execute a javascript function from within my Rails 4 application. I tried the following with ExecJS (https://github.com/sstephenson/execjs) without any success:
my_js_function = 'function my_function(a){var b=a.split("$");var…

Severin
- 8,508
- 14
- 68
- 117
1
vote
1 answer
therubyracer on windows - how to change gem file?
I want to run a heroku server and after installing ruby and ruby gems, wanted to run ' bundle install'.
I received a compile error when trying to install therubyracer and realised it is because therubyracer does not run on windows from here. It is…

franka
- 1,867
- 3
- 17
- 31
1
vote
0 answers
Rails: Could not find a JavaScript runtime while trying to run tests in rubymine
I have a rails 6.1 app with an rspec test suite running on ubuntu 20.04 and i use rubymine 2022.1.3 as an IDE when i try to run the tests from the Run configuration like spec for example or when i click on the icon next to the test definition i get…

alex
- 646
- 9
- 19
1
vote
1 answer
React::ServerRendering::PrerenderError in Search#show
I git this error React::ServerRendering::PrerenderError in Search#show from this scrip
<%= react_component('TagList', { tags: @tags }, { prerender: true }) %>
The errors are as below
Encountered error "#

Romeo
- 329
- 4
- 17
1
vote
2 answers
Call Javascript from Rails 6 Service Object
I'd like to call a Javascript library from a Service Object.
I have the following Javascript in /app/javascript/packs/readability.js.
import Readability from '@mozilla/readability';
function articleBody(document) {
var article = new…

Brad West
- 943
- 7
- 19