There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)

You should run following command to install NodeJS in Ubuntu

sudo apt-get install nodejs

or run this for OSX

brew install nodejs

Uglifier is a JS wrapper and it needs a JS runtime running or JS interpreter. I would choose to install NodeJS.


In the default Rails Gemfile, the line for the gem 'therubyracer' is commented out. If you uncomment it, you'll get that gem and it should work.

From "Getting Started with Rails":

Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime available on your system, in the absence of a runtime you will see an execjs error during asset compilation. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the therubyracer gem to the generated Gemfile in a commented line for new apps and you can uncomment if you need it. therubyrhino is the recommended runtime for JRuby users and is added by default to the Gemfile in apps generated under JRuby. You can investigate all the supported runtimes at ExecJS.