HOWTO: RubyOnRails + ExecJS + NodeJS - "Could not find a JavaScript runtime"



Reaction score: 12
Messages: 57


There is alot of questions across internet about getting NodeJS working with ExecJS. Normally it works but with never version it doesn't and produce below message when using with Passenger
Could not find a JavaScript runtime. See [url][/url] for a list of available runtimes.

I have installed www/node and accordingly modify rubygem /usr/local/lib/ruby/gems/1.9/gems/execjs-1.4.0/lib/execjs/runtimes.rb file. Please check your versions for ruby and ExecJS gem, because my path could be different to your. Below are changes done by me to get NodeJS working without TheRubyRacer etc...

--- runtimes.rb-orig    2012-11-04 16:09:09.112122307 +0000
+++ runtimes.rb 2012-11-04 15:57:36.934122659 +0000
@@ -20,7 +20,7 @@
     Node =
       :name        => "Node.js (V8)",
-      :command     => ["node"],
+      :command     => ["/usr/local/bin/node"],
       :runner_path => ExecJS.root + "/support/node_runner.js",
       :encoding    => 'UTF-8'

I didn't yet figure out why I have to specify full path to node. It is rather a workaround for current ExecJS or Passenger?.