Can't Start Rails Server - Could Not Find a JavaScript Runtime

Rails - Could not find a JavaScript runtime?

Installing a javascript runtime library such as nodejs solves this

To install nodejs on ubuntu, you can type the following command in the terminal:

sudo apt-get install nodejs

To install nodejs on systems using yum, type the following in the terminal:

yum -y install nodejs

Rails server does not start - Could not find a JavaScript runtime

I had the same error both for Windows and Ubuntu when I started working on Rails in January. The error is pretty straightforward. You need a JavaScript runtime environment for the server to start.

There are a number of solutions to this. The one I use on Ubuntu is to install NodeJS.

On Ubuntu you'd run something like the following to install NodeJS:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs

Those are the commands I use to do it as it will install the latest stable version of NodeJS, but you can just run sudo apt-get -y install nodejs and be fine.

On Windows, the answer I used, and there may be others, was to edit your Gemfile to install therubyracer. I work on Rails 4.0 RC1 apps right now and they all have gem 'therubyracer', platform: :ruby already in the Gemfile just commented out.

You can just go add gem 'therubyracer' in your Gemfile if you're running on Windows and that will get you running I'd bet. Then run bundle install.

Can't start Rails Server - Could not find a JavaScript runtime

You need a Javascript runtime. Execjs is in fact a wrapper around various runtimes you could use. You still need to install one of them. Several systems already bring a usable one (MacOS and Windows). On others, you need to install one.

In the error description, it pointed you towards https://github.com/sstephenson/execjs#readme which describes several of the supported runtimes (Hint: Always read error messages!). In your Gemfile, you'll notice that there is the therubyracer gem referenced (but commented out). It is one of the supported runtimes.

Thus, you could just uncomment this gem, run bundle install and be set.

Rails Server Could not find a JavaScript runtime

try to install latest nodejs.

more details can be found here ExecJS and could not find a JavaScript runtime

Why does Rails say it cannot find a JavaScript runtime?

You need to install node.js.

Check "Why does rails require JavaScript Runtime?."

ExecJS and could not find a JavaScript runtime

Ubuntu Users

I'm on Ubuntu 11.04 and had similar issues. Installing Node.js fixed it.

As of Ubuntu 13.04 x64 you only need to run:

sudo apt-get install nodejs

This will solve the problem.


CentOS/RedHat Users

sudo yum install nodejs


Related Topics



Leave a reply



Submit