運行Ruby On Rails 報錯:
ActionView::Template::Error (TypeError: 對象不支持此屬性或方法):
4: <title>ToyApp</title>
5: <%= csrf_meta_tags %>
6:
7: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8: <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9: </head>
10:
錯誤截圖可以看到 ExecJS::ProgramError
解決辦法有兩個:
1)刪除js文件的第15行,重啓 rail server
C:\toy_app\app\assets\javascripts\application.js
15: //= require_tree .
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require turbolinks
//= require_tree .
2)安裝nodejs,重啓rail server
$ node -v
v12.13.1
基於版本:
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
$ rails -v
Rails 5.1.7