HostOnNet Blog

Rails error runtimes.rb autodetect Could not find a JavaScript runtime

Looking for Linux Server Admin or WordPress Expert? We can help.

When i run a test Ruby On Rails application on a Ubuntu Docker Image, i get following error

oot@1975ae9d899e:/home/blog# bin/rails server
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:76:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:72:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:72:in `block in require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:61:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler/runtime.rb:61:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.1.pre.3/lib/bundler.rb:133:in `require'
    from /home/blog/config/application.rb:7:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
root@1975ae9d899e:/home/blog# 

This is fixed by installing Node.js

On Ubuntu, run

apt-get install nodejs

Posted in Ruby On Rails

One Response to Rails error runtimes.rb autodetect Could not find a JavaScript runtime

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.