簡體   English   中英

ExecJS :: ProgramError:嘗試為生產預編譯資產時出現意外字符'#'

[英]ExecJS::ProgramError: Unexpected character '#' when trying to precompile assets for production

我正在嘗試為Rails 4.1.1應用程序編譯資產,使用以下命令RAILS_ENV=production bundle exec rake assets:precompile但是當rails嘗試編譯資產時它會給我一個錯誤。

錯誤如下所示,

$ 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)

我嘗試使用--trace開關/選項運行上面提到的命令,但是對於導致此錯誤的原因我有點無能為力。 這個項目可以在這里查看=> https://github.com/ipatch/crj.com

demo.js是一個JavaScript文件,但使用的是CoffeeScript注釋( # )而不是JavaScript注釋( // )。

這很可能是因為rails會為您生成一個空的coffescript文件,作為您在項目中生成控制器的一部分。 您也可能將coffescript重命名為.js

在空的js文件中,您將找到coffescript的自動生成的注釋,該注釋以#而不是//由javascript使用。 只需刪除所有評論,您就可以開始了。

編輯

由於在您的示例的第13079行中找到了意外的'#'字符,因此您將在同一行找到您的評論。

請刪除任何.js文件中以“#”開頭的注釋行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM