Playing with ruby on rails, I encountered this annoying error:

[root@ip-10-181-25-234 some_application]# bin/rails server
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:94: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/rvm/gems/ruby-2.2.2/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/rvm/gems/ruby-2.2.2/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/rvm/gems/ruby-2.2.2/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/uglifier-3.1.13/lib/uglifier.rb:5:in `require'
/usr/local/rvm/gems/ruby-2.2.2/gems/uglifier-3.1.13/lib/uglifier.rb:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `require'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
/usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
/var/www/html/some_application/config/application.rb:7:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:88:in `require'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:88:in `block in server'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `tap'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `server'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
/var/www/html/some_application/bin/rails:9:in `require'
/var/www/html/some_application/bin/rails:9:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
/usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/var/www/html/some_application/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
        from /var/www/html/some_application/config/application.rb:7:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:88:in `require'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:88:in `block in server'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `tap'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `server'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
        from /var/www/html/some_application/bin/rails:9:in `require'
        from /var/www/html/some_application/bin/rails:9:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
        from /usr/local/rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /var/www/html/some_application/bin/spring:15:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'
[root@ip-10-181-25-234 some_application]#

now sure, its possible that you genuinly dont have execjs installed. In which case, simply gem install execjs. In my case, this wasnt solving the problem. After a bunch of experimentation, and googling. The problem ended up being solved by:

[root@ip-10-181-25-234 some_application]# yum -y install gcc-c++ make ; curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

This will install gcc-c++ and make. Then it will grab the setup for nodejs 6. It will then add some repos to yum. So next we simply install nodejs like we had it in our repos the whole time.

[root@ip-10-181-25-234 some_application]# yum install nodejs nodejs-devel
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: mirror.solarvps.com
 * extras: mirror.cogentco.com
 * updates: centos.mirror.constant.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:6.10.2-1nodesource.el6 will be installed
---> Package nodejs-devel.x86_64 2:6.10.2-1nodesource.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                Arch                             Version                                            Repository                            Size
=======================================================================================================================================================================
Installing:
 nodejs                                 x86_64                           2:6.10.2-1nodesource.el6                           nodesource                           9.8 M
 nodejs-devel                           x86_64                           2:6.10.2-1nodesource.el6                           nodesource                           420 k

Transaction Summary
=======================================================================================================================================================================
Install       2 Package(s)

Total download size: 10 M
Installed size: 36 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 10 M
(1/2): nodejs-6.10.2-1nodesource.el6.x86_64.rpm                                                                                                 | 9.8 MB     00:00
(2/2): nodejs-devel-6.10.2-1nodesource.el6.x86_64.rpm                                                                                           | 420 kB     00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   15 MB/s |  10 MB     00:00
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 34fa74dd: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
Userid : NodeSource <gpg-rpm@nodesource.com>
Package: nodesource-release-el6-1.noarch (installed)
From   : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 2:nodejs-6.10.2-1nodesource.el6.x86_64                                                                                                              1/2
  Installing : 2:nodejs-devel-6.10.2-1nodesource.el6.x86_64                                                                                                        2/2
  Verifying  : 2:nodejs-6.10.2-1nodesource.el6.x86_64                                                                                                              1/2
  Verifying  : 2:nodejs-devel-6.10.2-1nodesource.el6.x86_64                                                                                                        2/2

Installed:
  nodejs.x86_64 2:6.10.2-1nodesource.el6                                          nodejs-devel.x86_64 2:6.10.2-1nodesource.el6

Complete!
[root@ip-10-181-25-234 some_application]#

Now that its installed. Lets go back and try that bin/rails server again.

[root@ip-10-181-25-234 some_application]# bin/rails server -b0.0.0.0
=> Booting Puma
=> Rails 5.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
 * Version 3.8.2 (ruby 2.2.2-p95), codename: Sassy Salamander
 * Min threads: 5, max threads: 5
 * Environment: development
 * Listening on tcp://0.0.0.0:3000
 Use Ctrl-C to stop
 Processing by Rails::WelcomeController#index as HTML
  Parameters: {"internal"=>true}
  Rendering /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /usr/local/rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/templates/rails/welcome/index.html.erb (3.7ms)
Completed 200 OK in 24ms (Views: 7.7ms | ActiveRecord: 0.0ms)

As you can see it now works \0/