Rake Db:Create - Could Not Find a JavaScript Runtime

rake db:create - Could not find a JavaScript runtime

Ruby itself doesn't require a JS runtime, but a default new Rails application does.

There's a file called Gemfile in your main application directory (i.e. per Rails project) which is a list of gems required for your project that you can install using bundle install.

Adding the line gem 'therubyracer' and then bundle install will install the ruby racer JS runtime, which I've found to be the simplest if you're on a 64bit OS.

You can find more information about your Gemfile at the Bundler site.

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.

First rails install: Rake aborted no javascript runtime

Try fix it:

/usr/local/lib/ruby/gems/ruby_ver/gems/execjs-ver/lib/execjs/runtimes.rb

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

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

Does Rails rake db:migrate needs a javascript runtime?

You need a javascript runtime because now Rails uses an asset pipeline. Rails doesn't need it to run your migrations but when you run rake db:migrate, the rake task loads your rails application that needs a javascript runtime to start. Practically, there is no relation between the migrations and the javascript runtime but your app won't load without it.

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.

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