rails 在Win8 下出现ExecJS::RuntimeError

文章摘自http://ruby-china.org/topics/7523

execjs现在已经能认到Windows自带的CScript了所以windows下无需再装therubyracer和nodejs之类的JSRuntime

但是Win8下CScript默认接受js编码是UTF-8,而之前的CScript接受的是ASCII/GBK,或者用//U参数后接受UTF-16,解决方法是

修改execjsgem路径下execjs\runtimes.rb

JScript = ExternalRuntime.new(
    :name => "JScript",
    :command => "cscript //E:jscript //Nologo //U",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding => 'UTF-16LE'
)

改成

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
   :encoding    => 'UTF-8'
)

相关推荐