Could not find a JavaScript runtime

My Rails3.1 app worked fine on Windows but got the "Could not find JavaScript runtime" error when running on Linux.

Solution:

 

gem 'therubyracer', :platforms => :ruby

 The trick is knowing that :platforms => :ruby actually means only use this gem with "C Ruby(MRI) or Rubinius, but NOT Windows."

 

Windows has a builtin JavaScript engine which execjs can locate. On Linux there is not a builtin although there are plenty available to be installed. therubyracer is one of them.

 

Also, this problem could be resloved by installing nodejs

 

sudo apt-get install nodejs

 

 


版权声明:本文为kenniz原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。