Tags

Problem:
Gem Load Error is: Could not find a JavaScript runtime.

$ rails console
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.1/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>'

Solution A:
Edit the Gemfile and add/uncomment the line:
gem ‘therubyracer’, platforms: :ruby
Solution B:
sudo apt-get install nodejs

Advertisements