【问题标题】:No Javascript runtime on windows when running rails server运行 Rails 服务器时,Windows 上没有 Javascript 运行时
【发布时间】:2011-11-08 08:23:36
【问题描述】:

我是 Ruby on Rails 的新手,在我的 Windows PC 上设置它时遇到问题。我已成功按照http://rubyonrails.org/download 上的说明进行操作。但是,当我运行 rails server 命令时,我会得到以下输出:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `a
utodetect': Could not find a JavaScript runtime. See https://github.com/sstephen
son/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:5:in
 `<module:ExecJS>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:4:in
 `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_
script.rb:1:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_
script.rb:1:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-
script.rb:1:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-
script.rb:1:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-rails-3.1.1/lib/coffee-r
ails.rb:1:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/coffee-rails-3.1.1/lib/coffee-r
ails.rb:1:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:68:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:68:in `block (2 levels) in require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:66:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:66:in `block in require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:55:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runt
ime.rb:55:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:1
22:in `require'
        from C:/RoR/tickets/config/application.rb:7:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/comman
ds.rb:52:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/comman
ds.rb:52:in `block in <top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/comman
ds.rb:49:in `tap'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/comman
ds.rb:49:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

当我访问https://github.com/sstephenson/execjs 网站时,我仍然不确定如何进行。 谁能指出我正确的方向(记住我是新手)?谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 rubygems ruby-on-rails-3.1


    【解决方案1】:

    我也遇到过这个问题 我的解决方案就是添加

    C:\Windows\System32
    

    PATH

    然后重新启动您的计算机。

    【讨论】:

      【解决方案2】:

      我通过从http://nodejs.org/(安装链接)安装 node.js 使其工作 并将其安装路径(包括 node.exe)添加到我的 windows 用户' 路径的环境变量。我还在上面提到的 windows 变量中添加了杨的回复路径。

      【讨论】:

        【解决方案3】:

        这可能不是一个普遍流行的答案,但对于新用户,我会注释掉 gemfile 中加载 sass 和 coffeescript 的行。并不是说它们一点都不坏——但我认为它们给掌握框架的人增加了不必要的复杂性。或者,如果您已经熟悉这些组件,那么您只需要安装一个 javascript 运行时 - 我使用 node.js

        【讨论】:

        • 不要破坏框架以使其运行。此外,Sass 和 Coffeescript 的改进太大了,不容忽视。
        • 我按照你的建议做了——禁用了 sass 和 coffeescript gems——它可以工作!但是,一旦我想合并 JavaScript,我就必须弄清楚它,但我仍在努力了解 RoR 的工作原理,所以现在它可以工作。谢谢!
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-10-31
        • 1970-01-01
        • 1970-01-01
        • 2018-07-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多