ExecJS :: ProgramError:意外的标记:名称(选项) [英] ExecJS::ProgramError: Unexpected token: name (option)
问题描述
我的应用在本地环境中运行良好。我正在尝试将 git push
构建到heroku。我的命令是:
bundle install
git add。
git commit -amabcdef
git push heroku master
然后我遇到资产问题:precompile
remote:----->为Rails资产管道准备应用程序
remote:运行:rake资产:预编译
remote:I,[2016-01-04T08:32:35.471098#1018]信息 - :编写/ tmp / build_5d68c6d2f7845ca719a5f77705a12798 / public /assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js
遥控:I,[2016-01-04T08:32:35.471825#1018] INFO - :写入/tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/recruiters-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js.gz
remote:I,[2016-01-04T08:32:35.477826#1018]信息 - :写入/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.5信息 - :写作/tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js
remote:I,[2016-01-04T08:32:35.575465#1018]信息 - :写/ TMP / build_5d68c6d2f7845ca719a5f77705a12798 /公/资产/事件-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js.gz
远程:I,[2016-01-04T08:32:35.623887#1018] INFO - :写作的/ tmp / build_5d68c6d2f7845ca719a5f77705a12798 /公/资产/事件 - 31e95c603f03e300e73e01cd6ee747799da57b4d12924aa979e0fa0749681cca.css
遥控:I,[2016-01-04T08:32:35.624406#1018] INFO - :写入/tmp/build_5d68c6d2f7845ca719a5f77705a12798/public/assets/events-31e95c603f03e300e73e01cd6ee747799da57b4d12924aa979e0fa0749681cca.css.gz
远程:rake中止!
remote:ExecJS :: ProgramError:意外的标记:name(选项)(行:242,col:14,pos:7159)
remote:错误
remote:at new JS_Parse_Error(/ tmp / execjs20160104-1018-1ens1gjjs:2659:11936)
remote:在js_error(/ tmp / execjs20160104-1018-1ens1gjjs:2659:12155)
remote:在croak(/ tmp / execjs20160104-1018-1ens1gjjs :2659:20622)
remote:at token_error(/ tmp / execjs20160104-1018-1ens1gjjs:2659:20759)
remote:意外(/ tmp / execjs20160104-1018-1ens1gjjs:2659:20847)$ $ b $ remote:在分号(/ tmp / execjs20160104-1018-1ens1gjjs:2659:21317) / 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((
remote:croak((execjs):2659:20622)
remote:token_error((execjs):2659:20759)
remote:unexpected((execjs):2659:12155) :2659:20847)
remote:分号((execjs):2659:21320)
remote:simple_statement((execjs):2659:24179)
remote:(execjs):2659:22152
remote:(execjs):2659:21493
remote:block_((execjs):2659:26198)
请注意,我有特定于控制器的资产编译(参见下文)。我想知道这是否会导致这个问题。
views / layout / application.html.erb
<%= stylesheet_link_tagapplication,params [:controller],:media => all,data-turbolinks-track=> true%>
<%= javascript_include_tag'application',params [:controller],'data-turbolinks-track'=> true%>
initializers / assets.rb
#编译控制器资产
%w(招聘者事件表格候选人).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}
解决方案通过更新js语法,能够解决问题并且资产预编译成功。
原始
let option = {};
已更新
var option = {};
My app runs fine on local environment. I was trying to
git push
a build to heroku. My commands are:bundle install git add . git commit -am "abcdef" git push heroku master
I then encountered an issue with assets:precompile
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)
Note that I have controller-specific assets compile (see below). I wonder if that would cause the issue.
views/layout/application.html.erb
<%= stylesheet_link_tag "application", params[:controller], :media => "all", 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', params[:controller], 'data-turbolinks-track' => true %>
initializers/assets.rb
# Compile controller assets %w( recruiters events forms candidates ).each do |controller| Rails.application.config.assets.precompile += ["#{controller}.js", "#{controller}.css"] end
Any thoughts or suggestions?
Update I was able to locate where the issue is from. Though I'm not sure what is wrong and why it works fine locally.
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 }
解决方案By updating the js syntax, I was able to resolve the issue and the asset precompilation went successfully.
original
let option = {};
updated
var option = {};
这篇关于ExecJS :: ProgramError:意外的标记:名称(选项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!