TypeError: Object doesn't support this property or method

怎甘沉沦 提交于 2019-11-30 22:21:06

I removed the require_tree from application.js and it worked

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

The error occurs because there is some problem finding the correct assets which are located in app/assets. To resolve the issue, you can following below steps.

Add gem 'coffee-script-source', '1.8.0' into Gemfile and run bundle install then Run bundle update coffee-script-source Restart rails server Or there is a dirty workaround which is to change the code from

<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>

to

<%= stylesheet_link_tag "default", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "default", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>

But note this workaround doesn't really resolve the application issue, it just makes your application works without expected stylesheets and javascripts.

I think Best Solution is Removing the slashes in application.js file like

= require jquery
= require jquery_ujs
= require turbolinks
= require_tree .
Opy Osegs

I had this issue too, checkout the extensive solution on this thread, ExecJS::RuntimeError on Windows trying to follow rubytutorial by @Kevin P. Also,the solution by, @evedoevelli, on another thread: Rails ExecJS::ProgramError in Pages#home? works. I used the second solution with it been the most recent date-wise.

For me,solution was to remove-

 <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload'%>
 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

from

app\views\layout\application.html.erb

Upon careful research this is the solution I stumbled upon. Just make sure you have the latest version of NodeJs installed. After installing NodeJs, make sure you restart our system. However it is very important that you update your windows OS. You should be fine. If you are using RubyMine everything should work by now. No need to be troubling your head over the coffee-script issue. The ExecJs Program error seem to be more related to the NodeJs and its associated modules.

The reason is because NodeJS is not installed. If you install it, the problem should go away.

However, this would work as well in application.js:

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

But this is just not the prefered method because all this does is disable rails functionality. For example, ActionCable will not work with this change.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!