Rails - 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: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

libv8 is an OS library; you'll need to install the correct Linux system library. If you're running Ubuntu, it's

sudo apt-get install libv8-dev

Alternatively, you can install node.js which is available as a Debian/Ubuntu package for various distros, e.g. http://ppa.launchpad.net/chris-lea/node.js/ubuntu

You may save yourself a lot of trouble by deploying on Heroku instead where you don't have to manage the OS or components for gems.

rake aborted! Could not find a JavaScript runtime

The reason is pretty self explanatory and says that a JS runtime was not available. You can explicitly add that dependency by adding rubyracer gem to your rails application, and that should include the JS runtime, for you.

So, add gem 'therubyracer' to your Gemfile, and then, run bundle command, again. Then, you can run your rake or rails commands, as desired :)

If that does not solve your problem, install node.js on your system, and that should solve your problem, for sure. You can use:

sudo apt-get install nodejs # on ubuntu
brew install node # on mac-osx, if you have `homebrew` installed.

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

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



Related Topics



Leave a reply



Submit