Rails 3.1 "rails server" error Could not find a JavaScript runtime

September 19, 2011

This post was originally published in the Rambling Labs Blog on September 19, 2011.

I upgraded to rails 3.1.0 and created a new ‘test_app’.

rails new test_app

Got into the directory. Everything was fine, until I tried to run:

rails server

It threw a weird error:

Could not find a JavaScript runtime.
See https://github.com/sstephenson/execjs for a list of available runtimes.

That’s kinda weird. What does a rails app have to do with any JavaScript runtime? I guess it’s support for something that I still don’t know anything about.

I googled that and found a stackoverflow question. So, two solutions for the issue: either*** install nodejs*** or include “gem ‘execjs’” and “gem ‘therubyracer’” in the Gemfile and run bundle install.

Pick your favorite one and continue to do awesome apps with rails!