I'm trying to compile assets for a Rails 4.1.1 app, using the following command RAILS_ENV=production bundle exec rake assets:precompile
but when rails trys to compile the assets it gives me an error.
The error looks like the following,
$ RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected character '#' (line: 13079, col: 0, pos: 361024)
Error
at new JS_Parse_Error (<eval>:2357:10623)
at js_error (<eval>:2357:10842)
at parse_error (<eval>:2357:12560)
at Object.next_token [as input] (<eval>:2357:17582)
at next (<eval>:2357:18881)
at semicolon (<eval>:2357:19726)
at simple_statement (<eval>:2357:22538)
at <eval>:2357:20689
at <eval>:2357:19938
at <eval>:2357:31926
at Object.parse (<eval>:2358:98)
(in /opt/rails/crj.com/app/assets/javascripts/application.js)/home/capin/.gem/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/capin/.gem/ruby/2.1.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define'
/home/capin/.gem/ruby/2.1.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define'
V8::Error: Unexpected character '#'
at js_error (<eval>:2357:10842)
at parse_error (<eval>:2357:12560)
at next_token (<eval>:2357:17582)
at next (<eval>:2357:18881)
at semicolon (<eval>:2357:19726)
at simple_statement (<eval>:2357:22538)
at <eval>:2357:20689
at <eval>:2357:19938
at <eval>:2357:31926
at parse (<eval>:2358:98)
at <eval>:19:24
at <eval>:53:3
/home/capin/.gem/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/capin/.gem/ruby/2.1.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define'
/home/capin/.gem/ruby/2.1.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
I tried running the above metioned command with the --trace
switch / option, but am a little clueless as to what is causing this error. The project can be viewed in it's entirity here => https://github.com/ipatch/crj.com
demo.js is a JavaScript file, but is using CoffeeScript comments (#
) rather than JavaScript comments (//
).
It is most probably because rails auto-generated an empty coffescript file for you as part of you generating a controller in you project. You also probably renamed the coffescript to a .js
In the empty js file you'll find auto-generated comments for coffescript which starts with # instead of // used by javascript. Just remove all comments and you're good to go.
Since the unexpected '#' character was found on line 13079 of your example then you'll find your comments on that same line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With