I have a Ruby on Rails application deployed using capistrano on a server with ubuntu 16.04 + nginx + passenger5 + ruby 2.5.0 (via rbenv) + nodejs 9.4. For some unknown reason when I open the website passenger returns an error:
There was an error while trying to load the gem 'bootstrap'.
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes."
As said, I have nodejs installed and if I try to run the first ExecJS example via ruby console (irb) it works properly:
require "execjs"
ExecJS.eval "'red yellow blue'.split(' ')'"
If I change the javascript runtime by adding "therubyracer" gem to the Gemfile the project works properly. Any ideas why the ExecJS autodetection missing NodeJS?
Thanks in advance.
For some reason nginx/passenger cannot find the proper nodejs path. I've fixed this issued before by adding this to the top of my nginx configuration ( /etc/nginx/nginx.conf ):
end PATH;
Check: Rails/Passenger/Node.js: ExecJS "Could not find a JavaScript runtime" for more info.
Also, make sure the user in which nginx is executed (www-data?) is able to run node.