gpt4 book ai didi

ruby-on-rails - ExecJS::RuntimeError 在 cygwin (windows7) 上运行 Rails 入门博客

转载 作者:行者123 更新时间:2023-12-04 03:46:32 25 4
gpt4 key购买 nike

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

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)

节点已安装。

这是之后
$rails generate controller welcome index
$rails s

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

谢谢

乌布雷加琼

最佳答案

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

external_runtime.rb

compile_to_tempfile(source) do |file|
extract_result(@runtime.send(:exec_runtime, file.path))
end
end

应该改为
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

模块.rb

在最后两个 end 之前添加这个s。
def cygwin?
@cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
end

在此之后重新启动您的 Rails 服务器,如果幸运的话,它应该可以工作。

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

关于ruby-on-rails - ExecJS::RuntimeError 在 cygwin (windows7) 上运行 Rails 入门博客,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18599718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com