![Rails 服务器错误:“找不到 JavaScript 运行时。”](https://linux22.com/image/1130037/Rails%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%94%99%E8%AF%AF%EF%BC%9A%E2%80%9C%E6%89%BE%E4%B8%8D%E5%88%B0%20JavaScript%20%E8%BF%90%E8%A1%8C%E6%97%B6%E3%80%82%E2%80%9D.png)
尝试运行 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
- 评论宝石“therubyracer”。
- 安装nodejs。
- 再次运行服务器。