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

标签 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 服务器运行良好。

错误日志

App 2029 stdout: App 2029 stderr: sh: 1: App 2029 stderr: env: not found App 2029 stderr: App 2029 stdout: [ 2014-11-12 16:12:26.1580 1979/7feff83f9700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/ubuntu/apps/doger: An error occured while starting up the preloader. Error ID: b7381860 Error details saved to: /tmp/passenger-error-SUjzpL.html Message from application: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in autodetect'<br/> /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)>'<br/> /var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:inrequire' /var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in <top (required)>'<br/> /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in block (2 levels) in require'<br/> /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in each'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in block in require'<br/> /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in each'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in require'<br/> /var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler.rb:133:inrequire' /home/ubuntu/apps/doger/config/application.rb:7:in <top (required)>' /home/ubuntu/apps/doger/config/environment.rb:2:inrequire'
/home/ubuntu/apps/doger/config/environment.rb:2:in <top (required)>' config.ru:3:inrequire' config.ru:3:in block in <main>'<br/> /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:ininstance_eval'
/usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in initialize'<br/> config.ru:1:innew' config.ru:1:in <main>'<br/> /usr/share/passenger/helper-scripts/rack-preloader.rb:112:ineval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in preload_app'<br/> /usr/share/passenger/helper-scripts/rack-preloader.rb:158:in '
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>'<br/> /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in'

[ 2014-11-12 16:12:26.1691 1979/7feff60bf700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is b7381860. Please see earlier logs for details about the error.

gem 文件

# 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)

最佳答案

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

首先安装 Node :

sudo apt-get install nodejs

然后像这样将你的路径 env 添加到你的/etc/nginx/nginx.conf 中:

环境路径;

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

env PATH=/bin:/usr/bin;

关于ruby-on-rails - 找不到 JavaScript 运行时。有关可用运行时列表,请参阅 https ://github. com/sstephenson/execjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26891858/

相关文章:

node.js - npm 命令行工具的状态保存在哪里?

ruby-on-rails - `rails server` 抛出错误 "cannot load such file"-- sass/logger (LoadError)

mysql - 关联模型 ruby​​ on rails 上的一个数据库查询

ruby-on-rails - 缺少模板 PDFkit

mysql - 使用 Express 将多个 SQL 结果返回到 .handlebars

javascript - 为什么这个 node.js + mongoose 代码不保存到数据库中?

multithreading - 当 allow_concurrency = true 时 Rails 停止记录

javascript - 如何在 Rails 中呈现 json 表单的错误消息

javascript - 即使页面重新加载后,如何更改 Rails 中单选按钮的状态?

ruby - Chartkick Datepicker/Range Selector - 选择日期显示数据的可能性