Rails服务器无法找到JavaScript运行时

时间:2013-11-16 20:10:46

标签: ruby-on-rails-4

我收到以下错误。试图搜索并尝试安装extjs,bundler等gems仍然收到错误

harsha@harshamv:~/www/simple_cms$ rails s
/home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.2/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 /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.2/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.2/lib/execjs.rb:4:in `<top (required)>'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/uglifier-2.3.1/lib/uglifier.rb:3:in `require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/uglifier-2.3.1/lib/uglifier.rb:3:in `<top (required)>'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /home/harsha/www/simple_cms/config/application.rb:7:in `<top (required)>'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.1/lib/rails/commands.rb:74:in `require'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.1/lib/rails/commands.rb:74:in `block in <top (required)>'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.1/lib/rails/commands.rb:71:in `tap'
    from /home/harsha/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.1/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

2 个答案:

答案 0 :(得分:3)

尝试安装最新的nodejs。

更多细节可以在ExecJS and could not find a JavaScript runtime

找到

答案 1 :(得分:1)

Ubuntu用户

我在Ubuntu 11.04上遇到了类似的问题。安装Node.js修复了它。

从Ubuntu 13.04 x64开始,你只需要运行:

 sudo apt-get install nodejs

这将解决问题。

CentOS / RedHat用户

 sudo yum install nodejs

替代解决方案 只需在您的gem文件中添加ExecJS和Ruby Racer,然后运行bundle install。

   gem 'execjs'

  gem 'therubyracer'