Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

javascript - ExecJS::ProgramError: Unexpected token punc «(», expected punc «:» when running rake assets:precompile on production

When deploying my Rails app I get the following error:

rake aborted!
   ExecJS::ProgramError: Unexpected token punc ?(?, expected punc ?:? (line: 15, col: 14, pos: 265)

   Error
   at new JS_Parse_Error (/tmp/execjs20150524-4411-1p45n63js:2359:10623)
   at js_error (/tmp/execjs20150524-4411-1p45n63js:2359:10842)
   at croak (/tmp/execjs20150524-4411-1p45n63js:2359:19086)
   at token_error (/tmp/execjs20150524-4411-1p45n63js:2359:19223)
   at expect_token (/tmp/execjs20150524-4411-1p45n63js:2359:19446)
   at expect (/tmp/execjs20150524-4411-1p45n63js:2359:19584)
   at /tmp/execjs20150524-4411-1p45n63js:2359:28513
   at /tmp/execjs20150524-4411-1p45n63js:2359:19957
   at expr_atom (/tmp/execjs20150524-4411-1p45n63js:2359:27269)
   at maybe_unary (/tmp/execjs20150524-4411-1p45n63js:2359:30019)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)
   (execjs):2359:28513
   (execjs):2359:19957
   expr_atom ((execjs):2359:27269)
   maybe_unary ((execjs):2359:30019)

The file in question is valid, it works on localhost. I also tried running rake assests:precompile on localhost, it all passes. Finally, I tried to remove the content from the file, git push and redeploy - still got the same error. Only completely removing the file and re-deploying helps.

Would appreciate any ideas.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here I found help for the same problem you had.

Run rails console and:

JS_PATH = "app/assets/javascripts/**/*.js"; 
Dir[JS_PATH].each do |file_name|
  puts "
#{file_name}"
  puts Uglifier.compile(File.read(file_name), harmony: true)
end

It will show you the file and the line where the Uglifier is making the problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...