Sunday, August 12, 2012

Could not find a JavaScript runtime

Devs new to Linux will hit a 'Could not find a JavaScript runtime' error when trying to start a rails server.

The reason for this is Linux, by default, does not have an interface to a JavaScript engine.

Use one of these methods to install the interface required:

  1. Add The Ruby Racer gem to your Gemfile assets group:

    group :assets do
      gem 'therubyracer'
    end

    * Its a bit of a memory hog (Heroku discourage it) and you need to add it to every project you spin up on that machine.


  2. Install the Node.js package to your machine:

    sudo apt-get install nodejs

    * Distro specific installation: Installing Node.js by Package Manager