【问题标题】:Rails server command JavaScript runtime errorRails 服务器命令 JavaScript 运行时错误
【发布时间】:2017-01-21 20:48:22
【问题描述】:

我刚开始在 Rails 上学习 Ruby,一切正常,直到我 运行服务器我也重新安装了 Nodejs 并且没有锁。我在 Windows 10 上。 我也试过:gem updatebundle installgem bundle install。 我在 Git bash 上运行了所有命令。

            $ rails server
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
            Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
            Backtrace for gem load error is:
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `<top (required)>'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
            c:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
            c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
            bin/rails:4:in `require'
            bin/rails:4:in `<main>'
            Bundler Error Backtrace:
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
                    from c:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
                    from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
                    from bin/rails:4:in `require'
                    from bin/rails:4:in `<main>'

【问题讨论】:

  • 最简单的解决方案之一是安装nodenodejs.org
  • 我做到了,但仍然没有运气
  • 安装节点后是否也出现同样的错误?您是否将节点添加到 PATH 变量?
  • 我刚刚运行了安装程序,如何将节点添加到路径变量?
  • 试试node -v,如果你得到一个数字,安装程序会将节点路径添加到PATH环境变量中。重新打开命令提示符窗口并尝试启动 rails 服务器。

标签: javascript ruby-on-rails ruby node.js


【解决方案1】:

正如 Arun Kumar 所说,使用命令提示符运行配置了所有内容。所以使用命令提示符运行 Rails 服务器是有效的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 2018-07-07
    • 2016-10-01
    相关资源
    最近更新 更多