Rails 5 - ExecJS::RuntimeError

Rails 5 - ExecJS::RuntimeError

我的项目运行良好,我正在调整使用 chartkick 制作的图表并使用 ActionCable 更新 HTML 徽章,突然我收到此错误:

页面中的 ExecJS::RuntimeError#create_session

Showing B:/.../app/views/layouts/application.html.erb where line #7 raised:

SyntaxError: [stdin]:14:32: unexpected end of input
Extracted source (around line #7):              
5    <%= csrf_meta_tags %>
6    <%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
7    <%= javascript_include_tag 'application', 'chartkick' %>
8     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
10  </head>

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___430303067_44605968'
app/controllers/pages_controller.rb:145:in `render_page'
app/controllers/pages_controller.rb:46:in `create_session'

我用谷歌搜索并发现这个错误意味着我的系统上有一个 problem with the JavaScript runtime(我正在使用 Windows 10)。


我尝试过的事情:

  1. 删除 //= require_tree 。来自 application.js - 对我不起作用,因为那时我的所有 JavaScript 代码都不再起作用(我的项目使用 ActionCable)
  2. 修改C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems.3.0\gems\execjs-2.7.0\lib\execjs\ ru‌ ntimes.rb 原样 detailed here - 未修复
  3. 添加'therubyracer' gem - 无法安装,这是我得到的error message。这是完整的错误信息,然后它就完成了。据我所知,它无法安装,因为 Python 2 is not installed?
  4. 按照建议 here,我添加了 gem 'coffee-script-source' - 没有修复它,现在我无法删除它,因为突然其他 gems靠什么?奇怪.
  5. 自从我开始这个项目以来,我已经安装了 Node.js,所以不可能。

我正在使用 Windows 10、Ruby 2.3.0 和 Rails 5.0.2,这是我当前的 Gemfile

这是我的 application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require chartkick
//= require_tree .

我知道有很多关于这个问题的帖子,但是在尝试了几乎所有方法之后我有点迷路了...请帮忙! =)

在 Ziyan Junaideens 的指示之后,我搜索了我所有的 CoffeeScript 文件,最后发现我有一个未完成的方法调用... >_<

received: (data) ->
    App.online_status.  #<--- right here

那我学到了什么?永远不要在你累得要死的时候编程——否则你会在第二天花一整天的时间来寻找愚蠢的错误! ^^*

如果你有 gem # gem 'therubyracer', :platform=>:ruby 改为 gem 'mini_racer'