ruby-on-rails – ExecJS :: ProgramError:意外的令牌:名称(选项)

@H_301_1@我的应用在本地环境中运行良好.我试图将构建推送到heroku.我的命令是:
bundle install
git add .
git commit -am "abcdef"
git push heroku master

然后我遇到了资产问题:预编译

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        I,[2016-01-04T08:32:35.471098 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js
remote:        I,[2016-01-04T08:32:35.471825 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js.gz
remote:        I,[2016-01-04T08:32:35.477826 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
remote:        I,[2016-01-04T08:32:35.477974 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
remote:        I,[2016-01-04T08:32:35.575303 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js
remote:        I,[2016-01-04T08:32:35.575465 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js.gz
remote:        I,[2016-01-04T08:32:35.623887 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-31e95c603f03e300e73e01cd6ee747799da57b4d12924aa979e0fa0749681cca.css
remote:        I,[2016-01-04T08:32:35.624406 #1018]  INFO -- : Writing /tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-31e95c603f03e300e73e01cd6ee747799da57b4d12924aa979e0fa0749681cca.css.gz
remote:        rake aborted!
remote:        ExecJS::ProgramError: Unexpected token: name (option) (line: 242,col: 14,pos: 7159)
remote:        Error
remote:        at new JS_Parse_Error (/tmp/execjs20160104-1018-1ens1gjjs:2659:11936)
remote:        at js_error (/tmp/execjs20160104-1018-1ens1gjjs:2659:12155)
remote:        at croak (/tmp/execjs20160104-1018-1ens1gjjs:2659:20622)
remote:        at token_error (/tmp/execjs20160104-1018-1ens1gjjs:2659:20759)
remote:        at unexpected (/tmp/execjs20160104-1018-1ens1gjjs:2659:20847)
remote:        at semicolon (/tmp/execjs20160104-1018-1ens1gjjs:2659:21320)
remote:        at simple_statement (/tmp/execjs20160104-1018-1ens1gjjs:2659:24179)
remote:        at /tmp/execjs20160104-1018-1ens1gjjs:2659:22152
remote:        at /tmp/execjs20160104-1018-1ens1gjjs:2659:21493
remote:        at block_ (/tmp/execjs20160104-1018-1ens1gjjs:2659:26198)new JS_Parse_Error ((execjs):2659:11936)
remote:        js_error ((execjs):2659:12155)
remote:        croak ((execjs):2659:20622)
remote:        token_error ((execjs):2659:20759)
remote:        unexpected ((execjs):2659:20847)
remote:        semicolon ((execjs):2659:21320)
remote:        simple_statement ((execjs):2659:24179)
remote:        (execjs):2659:22152
remote:        (execjs):2659:21493
remote:        block_ ((execjs):2659:26198)

请注意,我有编译器特定的资产编译(见下文).我想知道这是否会导致这个问题.

视图/布局/ application.html.erb

<%= stylesheet_link_tag "application",params[:controller],:media => "all",'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application','data-turbolinks-track' => true %>

初始化/ assets.rb

# Compile controller assets
%w( recruiters events forms candidates ).each do |controller|
  Rails.application.config.assets.precompile += ["#{controller}.js","#{controller}.css"]
end

有什么想法或建议吗?

更新
我能够找到问题所在的位置.虽然我不确定什么是错的,为什么它在当地工作正常.

238        if (fieldClass.match(/(select|checkBox-group|radio-group)/)) {
 239          previewData.values = [];
 240  
 241          $('.sortable-options li',field).each(function() {
 242            let option = {};
      ==============^
      SyntaxError: missing ; before statement
 243            option.selected = $('.select-option',$(this)).is(':checked');
 244            option.value = $('.option-value',$(this)).val();
 245            option.label = $('.option-label',$(this)).val();
 246  
 247            previewData.values.push(option);
 248          });
 249        }

Syntax Error

解决方法

通过更新js语法,我能够解决问题并且资产预编译成功完成.

原版的

let option = {};

更新

var option = {};

相关文章

以下代码导致我的问题: class Foo def initialize(n=0) @n = n end attr_accessor :n d...
这是我的spec文件,当为上下文添加测试“而不是可单独更新用户余额”时,我得到以下错误. require 's...
我有一个拦截器:DevelopmentMailInterceptor和一个启动拦截器的inititializer setup_mail.rb. 但我想将...
例如,如果我有YAML文件 en: questions: new: 'New Question' other: recent: ...
我听说在RSpec中避免它,let,let !,指定,之前和主题是最佳做法. 关于让,让!之前,如果不使用这些,我该如...
我在Rails中使用MongoDB和mongo_mapper gem,项目足够大.有什么办法可以将数据从Mongoid迁移到 Postgres...