Rails 服务器错误:“找不到 JavaScript 运行时。”

Rails 服务器错误:“找不到 JavaScript 运行时。”

尝试运行 rails 服务器时出现此错误:

/var/lib/gems/2.1.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /var/lib/gems/2.1.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /var/lib/gems/2.1.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
    from /var/lib/gems/2.1.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:76:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:in `block in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler.rb:133:in `require'
    from /home/acne/Documents/WWW/web/config/application.rb:7:in `<top (required)>'
    from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:79:in `require'
    from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:79:in `block in server'
    from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:76:in `tap'
    from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:76:in `server'
    from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /usr/lib/ruby/vendor_ruby/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我该如何解决这个问题?感谢您的时间!

答案1

安装节点JS或安装therubyracer宝石

gem install therubyracer

答案2

  1. 评论宝石“therubyracer”。
  2. 安装nodejs。
  3. 再次运行服务器。

相关内容