ruby-on-railsrubynode.jscentosexecjs

Node.js not found by Rails / execjs


I have node.js installed by compiling and installing it from the root user. I think this maybe where the hangup is. From the user running the rails app I checked for node.js.

$ which node
/usr/local/bin/node

When I launched my rails app (Rails 3.2.9) I get the universally unhelpful "We're sorry, but something went wrong." Checking the the production error log I saw that the Javascript runtime was not found. That's confusing as it is obviously installed. So I went about forcing the Node javascript runtime. I edited config/boot.rb to include:

ENV['EXECJS_RUNTIME'] = 'Node'

I checked my app again, while watching the production log. This time I got the error

ActionView::Template::Error (Node.js (V8) runtime is not available on this system

Still confused. I went to the execjs gem and changed the runtime command to the exact installed path.

Node = ExternalRuntime.new(
  :name        => "Node.js (V8)",
  :command     => "/usr/local/bin/node",
  :runner_path => ExecJS.root + "/support/node_runner.js",
  :encoding    => 'UTF-8'
)

I still get the same error. Node is installed and accessible by the user but the gem/rails can't seem to use it. The server is run CentOS 6.3. The specific javascript file causing the error to be thrown is jquery.nivo.slider.pack.js. Which I didn't edit after downloading it from nivo.


Solution

  • I have had similar issue installing nodejs with source on my centos 6.3 system. It was successfully installed but I keep failing in compiling my ror app assets until I explicitly set the PATH to where it was installed (nodejs)

    [root]# make install
    ...
    installing /usr/local/lib/node_modules/npm/html/doc/folders.html
    symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
    updating shebang of /usr/local/bin/npm to /usr/local/bin/node

    [root]# export PATH=/usr/local/bin:$PATH

    Now it works. Hope that helps!