ExecJS :: ProgramError: Unexpected '#' character while trying to precompile assets for production

I am trying to compile resources for a Rails 4.1.1 application using the following command RAILS_ENV=production bundle exec rake assets:precompile , but when the rails try to compile assets, it gives me an error.

The error is as follows:

 $ 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 to execute the above metric command using the --trace switch / option parameter, but I don't know a bit what causes this error. The project can be viewed in this entirity here => https://github.com/ipatch/crj.com

+6
source share
3 answers

demo.js is a JavaScript file, but uses CoffeeScript ( # ) comments, not JavaScript ( // ) comments.

+14
source

Most likely, this is because the rails automatically generate an empty coffescript file for you, as part of creating a controller in your project. You probably also renamed coffescript to .js

In an empty js file, you will find auto-generated comments for coffescript that starts with C #, not the // used by javascript. Just delete all comments and you will go well.

EDIT

Since the unexpected "#" was found on line 13079 of your example, you will find comments on the same line.

+5
source

delete the comment line that starts with "#" in any of the .js file.

0
source

Source: https://habr.com/ru/post/973879/


All Articles