Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

Ubuntu Users:

I had the same problem and I fixed it by installing nodejson my system independent of the gem.

on ubuntu its: sudo apt-get install nodejs

I'm using 64bit ubuntu 11.10

update: From @Galina 's answer below I'm guessing that the latest version of nodejs is required, so @steve98177 your best option on a redhat(or CentOS) box is to install from source code as @Galina did, but as you can't "make/install" on this box ?, I suggest you try to install a fedora rpm(long shot) https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager or find another RH/CentOs box(that you can 'make' on) and create your own rpm and install on original RH box(if old glibc on RH plays nice).

The real issue here(IMHO) is installing Gems that have dependencies on installed packages outside of the ruby environment, is there a way of knowing before installing ? an RFI for Gems or bundler ?


CentOS/RedHat Users:

sudo yum install nodejs

In your gemfile add:

gem 'execjs'
gem 'therubyracer', :platforms => :ruby

For more details: ExecJS and could not find a JavaScript runtime


This is the link I needed to fix the problem (install nodejs): https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager


When you create an empty project, this line is commented in Gemfile. Just uncomment it and bundle!

gem 'therubyracer', :platforms => :ruby

I had similar issues on ubuntu 12.04. Installing Node.js fixed it.


If you were on ubuntu $ sudo apt-get install nodejs

Try to don't use another systems like Windows to development. Think that almost all servers in the world are Linux servers, so when you try to deploy that application it will be easier if you have developed that on a Linux or Unix environment too.