Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug asset prompiling syntax errors?

I'm trying to push to Heroku after some Frontend touching, but I have several errors when precompiling (I think syntax errors).

The thing is, I get the line number of the precompiled assets, not the original ones, so I don't know how to debug it.!

  ExecJS::ProgramError: Unexpected token: operator (<) (line: 20575, col: 0, pos: 641944)
       Error
       at new JS_Parse_Error (/tmp/execjs20141029-3052-g386xfjs:2357:10623)
       at js_error (/tmp/execjs20141029-3052-g386xfjs:2357:10842)
       at croak (/tmp/execjs20141029-3052-g386xfjs:2357:19067)
       at token_error (/tmp/execjs20141029-3052-g386xfjs:2357:19204)
       at unexpected (/tmp/execjs20141029-3052-g386xfjs:2357:19292)
       at /tmp/execjs20141029-3052-g386xfjs:2357:27484
       at /tmp/execjs20141029-3052-g386xfjs:2357:29977
       at expr_ops (/tmp/execjs20141029-3052-g386xfjs:2357:30735)
       at /tmp/execjs20141029-3052-g386xfjs:2357:30827
       at /tmp/execjs20141029-3052-g386xfjs:2357:31270
like image 348
Gibson Avatar asked Oct 19 '22 23:10

Gibson


1 Answers

Normally you can still compile your assets locally in this situation and then go to the line in question in you compiled application.js file.

So

bundle exec rake assets:precompile

(you need to have a local "production" database to run this bundle exec rake db:create:all)

then open public/assets/application-some_md5_hash.js in your editor

In your case you would go to line 20575 and look for a crazy < somewhere

Make sure you clean up and remove your public/assets folder so you don't accidentally check it into version control

I'm pretty sure this will also work in the situation that you have funky CSS by going to the application-md5stuff.css

like image 99
mraaroncruz Avatar answered Oct 23 '22 07:10

mraaroncruz