Could not find JavaScript executable. See https://github.com/sstephenson/execjs for a list of available runtimes

I have a problem with Rails 4.1.7, Phusion Passenger version 4.0.53, nginx / 1.6.2 on the ubuntu 14.04 AWS Instance server, but it works well with the rails server.

error.log

App 2029 stdout: Application 2029 stderr: sh: 1: Application 2029 stderr: env: not found application 2029 stderr: application 2029: [2014-11-12 16: 12: 26.1580 1979 / 7feff83f9700 Pool2 / Implementation.cpp: 287]: Failed to create process for application / home / ubuntu / apps / doger: an error occurred while starting the preloader. Error ID: b7381860 Error information saved to: /tmp/passenger-error-SUjzpL.html Message from application: Could not find JavaScript executable. See https://github.com/sstephenson/execjs for a list of available Battery Life. (ExecJS :: RuntimeUnavailable)
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in ' /var/lib/gems/1.9.1/gems/ execjs-2.2.2 / lib / execjs.rb: 4: inautodetect'
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs.rb:5:in

<top (required)>'
/var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in
require '/ var / lib / gems / 1.9.1 / gems / uglifier-2.5.3 / lib / uglifier.rb: 3: in require' /var/lib/gems/1.9.1/gems/bundler-1.7.6 /lib/bundler/runtime.rb:76:in each ' /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:61:in requires '/home/ubuntu/apps/doger/config/application.rb:7:in require' / home /ubuntu/apps/doger/config/environment.rb::in require 'config.ru∗:in instance_eval' /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in new 'config.ru: 1: in eval ' /usr/share/passenger/helper-scripts/rack-preloader.rb:112:in '<top (required)>'
/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

block in require'
/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
<top (required)>' /home/ubuntu/apps/doger/config/environment.rb:2:in
<top (required)>' config.ru:3:inblock in <main>'
/usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in

initialize'
config.ru:1:in
<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in

preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158:in

/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>'
/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] Checkout failed because a spawning error occurred. The identifier is error b7381860. More details about the error.

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

I already installed nodejs (v0.10.25)

+4
source share
2 answers

I get this problem every time I set up a new ubuntu / nginx / passenger / rails server. try it

First install node:

sudo apt-get install nodejs

then add your env path to your /etc/nginx/nginx.conf, for example:

env PATH;

or be more specific (if node is located in / usr / bin / nodejs):

env PATH=/bin:/usr/bin;

+11
source

Uncomment 'therubyracer', :

gem 'therubyracer',  platforms: :ruby

. , .

+4

All Articles