微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

找不到 JavaScript 运行时有关可用运行时的列表,请参阅 https://github.com/rails/execjs (ExecJS::RuntimeUnavailable)

如何解决找不到 JavaScript 运行时有关可用运行时的列表,请参阅 https://github.com/rails/execjs (ExecJS::RuntimeUnavailable)

在这台服务器上有其他 Rails 应用程序工作正常...
我的服务器上安装了 nodejs
我在 gemfile 中有 gem 'therubyracer',platforms: :ruby
我试试bundle install
我在 prod conf 中尝试 config.assets.js_compressor = Uglifier.new(harmony: true)

但没有解决问题...

 [passenger_native_support.so] trying to compile for the current user (www-data) and Ruby interpreter...
     (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)
     Warning: compilation didn't succeed. To learn why,read this file:
     /var/www/ddemarque/passenger_native_support-hxohsj.log
 [passenger_native_support.so] finding downloads for the current Ruby interpreter...
     (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable)
     Could not download https://github.com/phusion/passenger/releases/download/release-6.0.8/rubyext-ruby-2.5.1-x86_64-linux.tar.gz: no download tool found (curl or wget required)
     Trying next mirror...
     Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/6.0.8/rubyext-ruby-2.5.1-x86_64-linux.tar.gz: no download tool found (curl or wget required)
     Trying next mirror...
     Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/6.0.8/rubyext-ruby-2.5.1-x86_64-linux.tar.gz: no download tool found (curl or wget required)
 [passenger_native_support.so] will not be used (can't compile or download) 
  --> Passenger will still operate normally.
Error: The application encountered the following error: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in `autodetect'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/execjs-2.8.1/lib/execjs.rb:5:in `<module:ExecJS>'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/execjs-2.8.1/lib/execjs.rb:4:in `<top (required)>'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `each'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `block in require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `each'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `require'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.2.15/lib/bundler.rb:173:in `require'
    /var/www/ddemarque/config/application.rb:7:in `<top (required)>'
    /var/www/ddemarque/config/environment.rb:2:in `require_relative'
    /var/www/ddemarque/config/environment.rb:2:in `<top (required)>'
    config.ru:3:in `require_relative'
    config.ru:3:in `block in <main>'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `instance_eval'
    /home/USER/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `initialize'
    config.ru:1:in `new'
    config.ru:1:in `<main>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `eval'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `preload_app'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:390:in `run_block_and_record_step_progress'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:188: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>'

解决方法

我从 2.8.1 开始强制 gem execjs 降到 2.7.0,它的工作原理...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。