找不到JavaScript运行时。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs

时间:2014-11-12 16:32:27

标签: ruby-on-rails node.js ruby-on-rails-4 nginx passenger

我在Ubuntu服务器14.04 AWS实例中遇到了Rails 4.1.7,Phusion Passenger版本4.0.53,nginx / 1.6.2的问题,但是使用rails服务器运行良好。

error.log

  

App 2029 stdout:App 2029 stderr:sh:1:App 2029 stderr:env:not   发现App 2029 stderr:App 2029 stdout:[2014-11-12 16:12:26.1580   1979/7feff83f9700 Pool2 / Implementation.cpp:287]:无法生成   申请/ home / ubuntu / apps / doger的过程:发生错误   启动预加载器时。错误ID:b7381860错误详细信息   保存到:/tmp/passenger-error-SUjzpL.html来自应用程序的消息:   找不到JavaScript运行时。看到   https://github.com/sstephenson/execjs获取可用列表   运行时间。 (ExecJS :: RuntimeUnavailable)
  /var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in   autodetect'
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs.rb:5:in
'
  /var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs.rb:4:in <top (required)>'
/var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in
要求&#39;   /var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in <top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in
要求&#39;
  /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in   block (2 levels) in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in
各&#39;
  /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in   block in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in
各&#39;
  /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in   require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler.rb:133:in
需要&#39;   /home/ubuntu/apps/doger/config/application.rb:7:in <top (required)>' /home/ubuntu/apps/doger/config/environment.rb:2:in要求&#39;
  /home/ubuntu/apps/doger/config/environment.rb:2:in <top (required)>' config.ru:3:in要求&#39; config.ru:3:in block in <main>'
/usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in
instance_eval&#39;
  /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in initialize'
config.ru:1:in
new&#39; config.ru:1:in <main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in
eval&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:112:in   preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158:in
&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in   <module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in
&#39;

     

[2014-11-12 16:12:26.1691 1979 / 7feff60bf700   agents / HelperAgent / RequestHandler.h:2306]:[客户端20]不能   结帐会话,因为发生了产生错误。的标识符   错误是b7381860。有关详细信息,请参阅前面的日志   错误。

的Gemfile

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.7'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

我已经安装了nodejs(v0.10.25)

3 个答案:

答案 0 :(得分:14)

每次设置新的ubuntu / nginx / passenger / rails服务器时都会出现此问题。试试这个

首次安装节点:

sudo apt-get install nodejs

然后将您的路径env添加到/etc/nginx/nginx.conf中,如下所示:

env PATH;

或更具体(如果节点位于/ usr / bin / nodejs):

env PATH=/bin:/usr/bin;

答案 1 :(得分:4)

取消注释'therubyracer'宝石,如下所示:

gem 'therubyracer',  platforms: :ruby

并运行bundle install。我希望这会对你有所帮助。

答案 2 :(得分:0)

我遇到了类似的问题,我的机器上已经运行了 nodejs。看了这么多,我才意识到我需要在我的 Gemfile 中包含 execjs gem:

gem "execjs", "~> 2.8.1"

然后运行 ​​bundle install