在cygwin上运行Getting Rails博客的ExecJS :: RuntimeError(windows7)

umb*_*ong 5 ruby-on-rails

我正在尝试在cygwin上运行Rails入门博客(windows7).我收到以下错误消息:

Welcome#index中的ExecJS :: RuntimeError

module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\tmp\execjs20130903-50672-1vn7gqc.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

  (in /usr/lib/ruby/gems/1.9.1/gems/turbolinks-1.3.0/lib/assets/javascripts   /turbolinks.js.coffee)
Run Code Online (Sandbox Code Playgroud)

节点已安装.

这是在之后

$rails generate controller welcome index
$rails s
Run Code Online (Sandbox Code Playgroud)

我在cygwin上运行Rails 4.0任何想法为什么会发生这种情况?

谢谢

umbregachoong

Yum*_*mos 2

我遇到了这个错误,它与临时文件的路径错误有关。我能够通过更改 .txt 中的以下两个文件来修复它\gems\[ruby version]\gems\execjs-2.0.2\lib\execjs。(可能在 中找到\usr\lib\ruby\,但这取决于您的 Ruby 安装方式。我使用的是 RVM,所以我的有所不同。)

外部运行时.rb

compile_to_tempfile(source) do |file|
     extract_result(@runtime.send(:exec_runtime, file.path))
  end
end
Run Code Online (Sandbox Code Playgroud)

应该改为

compile_to_tempfile(source) do |file|
    filepath = file.path
    if ExecJS.cygwin? && @runtime.name == "JScript"
      IO.popen("cygpath -m " + file.path) { |f| filepath = f.read }
      filepath = filepath.gsub("\n","")
    end
    extract_result(@runtime.send(:exec_runtime, filepath))
  end
end
Run Code Online (Sandbox Code Playgroud)

模块.rb

将其添加到最后两个ends 之前。

def cygwin?
  @cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
end
Run Code Online (Sandbox Code Playgroud)

重启 Rails 服务器后,如果运气好的话,它应该可以工作了。

来源: https: //github.com/sstephenson/execjs/issues/78