简体   繁体   English

由于“ uglifier”,无法启动Ruby-on-rails Web应用程序

[英]Ruby-on-rails web application could not be started because of 'uglifier'

There was an error while trying to load the gem 'uglifier'. 尝试加载gem'uglifier'时出错。

Gem Load Error is: wrong argument type Class (expected Module)
Backtrace for gem load error is:

/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:23:in `include'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:23:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:22:in `class_eval'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:22:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:21:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:21:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8.rb:22:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.2/lib/v8.rb:22:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:108:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:108:in `available?'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `find'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `best_available'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:57:in `autodetect'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/2.4.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
/var/www/geia.junyuzhu.com/public_html/testapp/config/application.rb:7:in `<top (required)>'
/var/www/geia.junyuzhu.com/public_html/testapp/config/environment.rb:2:in `require_relative'
/var/www/geia.junyuzhu.com/public_html/testapp/config/environment.rb:2:in `<top (required)>'
config.ru:3:in `require_relative'
config.ru:3:in `block in <main>'
/usr/local/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
Bundler Error Backtrace:
 (Bundler::GemRequireError)
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `each'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `block in require'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `each'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
  /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
  /var/www/geia.junyuzhu.com/public_html/testapp/config/application.rb:7:in `<top (required)>'
  /var/www/geia.junyuzhu.com/public_html/testapp/config/environment.rb:2:in `require_relative'
  /var/www/geia.junyuzhu.com/public_html/testapp/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require_relative'
  config.ru:3:in `block in <main>'
  /usr/local/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
  /usr/local/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

I have tried to install nodejs and restart the apache server. 我尝试安装nodejs并重新启动apache服务器。 It doesn't help with this issue. 它对解决这个问题没有帮助。

bundle show uglifier gives bundle show uglifier

/usr/local/lib/ruby/gems/2.4.0/gems/uglifier-3.0.4

I assume I have uglifier installed correctly. 我假设我已经正确安装了uglifier。

Also gem 'therubyracer', platforms: :ruby is uncommented in Gemfile. 还有gem 'therubyracer', platforms: :ruby在Gemfile中未注释。

Please help, I have no idea how to solve this issue. 请帮助,我不知道如何解决此问题。

This is a known issue with therubyracer and Ruby 2.4. 这是therubyracer和Ruby 2.4的一个已知问题 There are a couple of additional issues with Ruby 2.4 compatibility which are tracked in their issue tracker at https://github.com/cowboyd/therubyracer/issues/430 . 在其问题跟踪器中的https://github.com/cowboyd/therubyracer/issues/430上可以跟踪与Ruby 2.4兼容性有关的其他一些问题。

You should use an earlier version of Ruby, eg 2.3.3 until a new version is therubyracer is released. 您应该使用早期版本的Ruby,例如2.3.3,直到发布新版本therubyracer。

BTW: There are several gems which are not yet compatible with Ruby 2.4. 顺便说一句:有些宝石与Ruby 2.4尚不兼容。 In order to shield you from experiencing a large amount of compatibility issues after a new release, it is probably wise to not upgrade on first day of release 为了使您免于在新版本发布后遇到大量的兼容性问题,明智的做法是在发布的第一天不进行升级

In the default rails Gemfile , the line for the gem therubyracer is commented out. 在默认的rails Gemfile ,注释了gem therubyracer的行。 If you uncomment it, you'll get that gem and it should work. 如果您取消注释,则将获得该宝石,它应该可以工作。 (solved the problem for me) (为我解决了问题)

OR 要么

Run Following Commend 追随表彰

sudo apt-get install nodejs

Uglifier is a JS wrapper and it needs a JS runtime running or an JS interpreter Uglifier是一个JS包装器,它需要运行JS运行时或JS解释器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM