- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将新的 Rails 应用程序部署到 Heroku。该应用程序在我的机器上运行得很好,我可以将它从 github 拉到另一台机器上,它在那里也运行得很好。
但是当尝试部署到 Heroku 时,情况就不同了。我一直在网上搜索类似的错误如下:
ExecJS::ProgramError: Unexpected token name «of», expected punc «;» (line: 29885, col: 15, pos: 861062)
我在 stackoverflow 上看到的大多数问题在跟踪中都有错误线索。但我的跟踪没有提供太多线索(第 29885 行...?意外的标记“of”...在哪里??)。我有一个问题here我概述了我在 js 开发者控制台中发现的内容,但它 Bootstrap 我走向错误的方向。
所有页面在本地运行良好。
除了浏览器开发者控制台之外,还有哪些方法可以解决此类错误?
$ RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected token name «of», expected punc «;» (line: 29885, col: 15, pos: 861062)
Error
at new JS_Parse_Error (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:10623)
at js_error (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:10842)
at croak (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:19086)
at token_error (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:19223)
at expect_token (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:19446)
at expect (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:19584)
at regular_for (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:23361)
at for_ (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:23316)
at /private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:21220
at /private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:19957
at block_ (/private/var/folders/7g/kc34ywms5j9bb5qgfcr0c7tw0000gn/T/execjs20150822-14064-japh2djs:2359:24599)new JS_Parse_Error ((execjs):2359:10623)
js_error ((execjs):2359:10842)
croak ((execjs):2359:19086)
token_error ((execjs):2359:19223)
expect_token ((execjs):2359:19446)
expect ((execjs):2359:19584)
regular_for ((execjs):2359:23361)
for_ ((execjs):2359:23316)
(execjs):2359:21220
(execjs):2359:19957
block_ ((execjs):2359:24599)
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:39:in `exec'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:21:in `eval'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:46:in `call'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/uglifier-2.7.1/lib/uglifier.rb:212:in `run_uglifyjs'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/uglifier-2.7.1/lib/uglifier.rb:179:in `compile'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/uglifier_compressor.rb:52:in `call'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/loader.rb:126:in `load_from_unloaded'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/loader.rb:60:in `block in load'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/loader.rb:286:in `fetch_asset_from_dependency_cache'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/loader.rb:44:in `load'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/base.rb:66:in `find_asset'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/manifest.rb:138:in `block in find'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/path_utils.rb:204:in `each'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/path_utils.rb:204:in `stat_directory'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/path_utils.rb:222:in `stat_tree'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:105:in `each'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:104:in `each'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/manifest.rb:136:in `find'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/sprockets/manifest.rb:162:in `compile'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-3.3.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/Travis/.rvm/gems/ruby-2.2.1/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/Travis/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/Travis/.rvm/gems/ruby-2.2.1/bin/rake:23:in `load'
/Users/Travis/.rvm/gems/ruby-2.2.1/bin/rake:23:in `<main>'
/Users/Travis/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/Travis/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile
Heroku 日志向我显示了与上面相同的信息。
我的application.js文件:
// 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, vendor/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.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
//= require chartkick
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
更新:
删除js相关文件并尝试一一部署后,发现有问题的代码如下(删除它可以让我毫无问题地部署到heroku......奇怪的是,任何在开发中使用此代码的页面在浏览器开发者控制台中不会产生 js 错误,并且它们的运行没有问题)
//assets/javascripts/accounts.js
$(document).on('page:change', function() {
// var getFieldCount = function() {
// var accountType = $('#account_type').val();
// return $('.field.' + accountType).size();
// };
// Add classes to label each field under its account type for later easy grabbing in jQueries
var accountFields = {}
try {
accountFields = JSON.parse($('#account_fields').val());
} catch(jsonException) {
//ignore errors without crashing
}
for (var accountType in accountFields) {
var fields = accountFields[accountType];
for (field of fields) {
var field = $('#account_' + field).closest('.field');
field.addClass(accountType);
}
}
if ($('#edit_account').size() > 0) {
var showCorrectFieldsPerAccountType = function() {
$('.field').hide();
var accountType = $('#account_type').val();
var fields = accountFields[accountType];
for (field of fields) {
var field = $('#account_' + field).closest('.field');
field.show();
}
};
$('#account_type').change(showCorrectFieldsPerAccountType);
showCorrectFieldsPerAccountType();
}
if ($('#new_account').size() > 0) {
var showCorrectFieldsPerAccountType = function() {
$('.field').hide();
var accountType = $('#account_type').val();
var fields = accountFields[accountType];
for (field of fields) {
var field = $('#account_' + field).closest('.field');
field.show();
}
};
$('#account_type').change(showCorrectFieldsPerAccountType);
showCorrectFieldsPerAccountType();
$("#account_type").prepend("<option value='' selected='selected'>Please Select</option>");
}
});
最佳答案
如果您在 JS lint 工具(如 http://www.javascriptlint.com/online_lint.php)中加载有问题的脚本(在您的更新中) ,您将看到该行的错误:
for (field of fields) {
这行似乎是导致原始错误的原因:
ExecJS::ProgramError: Unexpected token name «of», expected punc «;» (line: 29885, col: 15, pos: 861062)
关于javascript - 排除 Rails 部署的 Heroku ExecJS 程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32131451/
我有一个名为“members”的数据库表。分配给成员的是一个职位。 职位 来自部门。我有 Departments,然后是那些中的 Sub-Departments 和 Sub-Departments 中
我正在尝试为 Solr 搜索应用过滤器标记 Tagging_and_excluding_Filters . 挑战在于同时应用多个标记(对于单个页面上的多个选择选项)。例如 q=mainquery&fq
我知道这个问题已经被问过很多次了,我已经尝试了所有建议,并阅读了有关不同选择器等的所有内容,但没有任何对我有用 给出以下 HTML 片段: link
是否有直接的 LINQ 语法来查找集合 B 中不存在的集合 A 的成员?在 SQL 我会写这个 SELECT A.* FROM A LEFT JOIN B ON A.ID = B.ID WHERE B
我试图排除并在现有xpath中包括以下xpath,但不太确定如何做到这一点 //exclude -> //*[@id="ires"]/ol/li[6]/div/a[1]/img //include
我有 30 个站点,我需要在其中 24 个站点上回显某些内容。我怎样才能排除其他人?该代码不起作用,因为我认为它的逻辑是假的:) $currentsite = get_bloginfo('wpurl'
我需要对目标文件夹进行检查,并检查文件是否来自今天,并且超过5kb 下面的命令根据使用今天的日期存在的文件来提供bool值,但是我还要添加-gt5kb之类的排除项 我尝试使用-Exlcude,但不确定
我编入索引的Elasticsearch文档包含许多字段。我一直在使用match_all查询来获取结果。我想从match_all中排除一些字段,这可能吗? 最佳答案 在Elasticsearch中,您可
我正在为我的 DAO 编写一些测试,因为很多测试使用保存到我的数据库中的测试对象,所以我使用注释 @Before 和 @Before 创建了 setup() 和teardown() 方法@After
我编写了一个程序来解决以下问题: Implement a diffusion limited aggregation simulation on a toroid plane where seeds
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
很多时候我必须运行这个查询: select * from users where name is not null and name != '' 有没有更好的方法来做到这一点。我需要更多的性能,任何建
如果检测到某个操作系统,是否有一种简单的方法可以排除某些代码? 我设计了一个运行良好的网站(它是一个 sidescroller),当使用滚轮(向上/向下)时,它会左右滚动。但是,如果您使用的是 Mac
我应该如何排除“IN”子句中的值? $Graduates = "45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,6
很明显,如果一个 Mysql 表的全文索引包含一个出现在 50% 的数据行中的关键字,该关键字将被匹配查询忽略 因此,如果我有一个包含 50 个条目的全文索引“content”的表其中 27 个条目在
我有下面的循环。 我需要提取所有不包含字母 p 的名称 (lskey),但我的尝试不起作用。 for(var i = 0; i "); } } 如果有人能回答,我将不胜感激。 最佳答案 如此接
我正在尝试查找 FTP 服务器上根目录的总大小。但是,我无权访问根目录中的其中一个目录。 我想用这个函数对根目录的大小求和: size = 0 for filename in ftp.nlst("."
我有以下正则表达式来匹配 html 链接: 有点效果。除了不是真的。因为它在 编辑: 这将使它只抓取引号而不是 之后的所有内容 最佳答案 我认为您的正则表达式没有按照您的意愿行事。 这会非贪婪地捕
我在提出异常方面遇到困难,例如: import csv o = open('/home/foo/dummy.csv', 'r') # Empty file! reader = csv.reader(o
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我是一名优秀的程序员,十分优秀!