Search code examples
ruby-on-railsnode.jsrubygemsinstallationuglifier

uglifier gem load error / download node.js?


I am getting started with Ruby on Rails, and following the steps at InstallRails... I have created the sample_app on the desktop, and now I cannot create the server.

My command

$ rails server

is answered with the following

...There was an error while trying to load the gem 'uglifier'.  etc

I have read several threads here and elsewhere, such as this one and this one... In the latter there seems to bea solution, which I can't understand.... I cannot download node.js! or nodejs? What is my command and directory in Gitbash to download it?


Solution

  • It requires JS runtime. Just install gem therubyracer for the JS runtime. In the default rails Gemfile,uncomment the line for the gem 'therubyracer' which is commented out.If you dont find it add the gem to your Gemfile like

    gem 'therubyracer'
    

    Then run

    bundle install
    

    The gem will be installed and it should work.

    Otherwise you can install node.js.

    For ubuntu

    sudo apt-get install nodejs
    

    For mac

    brew install nodejs