简体   繁体   English

ExecJS :: ProgramError:尝试为生产预编译资产时出现意外字符'#'

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

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. 我正在尝试为Rails 4.1.1应用程序编译资产,使用以下命令RAILS_ENV=production bundle exec rake assets:precompile但是当rails尝试编译资产时它会给我一个错误。

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. 我尝试使用--trace开关/选项运行上面提到的命令,但是对于导致此错误的原因我有点无能为力。 The project can be viewed in it's entirity here => https://github.com/ipatch/crj.com 这个项目可以在这里查看=> https://github.com/ipatch/crj.com

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

It is most probably because rails auto-generated an empty coffescript file for you as part of you generating a controller in you project. 这很可能是因为rails会为您生成一个空的coffescript文件,作为您在项目中生成控制器的一部分。 You also probably renamed the coffescript to a .js 您也可能将coffescript重命名为.js

In the empty js file you'll find auto-generated comments for coffescript which starts with # instead of // used by javascript. 在空的js文件中,您将找到coffescript的自动生成的注释,该注释以#而不是//由javascript使用。 Just remove all comments and you're good to go. 只需删除所有评论,您就可以开始了。

EDIT 编辑

Since the unexpected '#' character was found on line 13079 of your example then you'll find your comments on that same line. 由于在您的示例的第13079行中找到了意外的'#'字符,因此您将在同一行找到您的评论。

请删除任何.js文件中以“#”开头的注释行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ExecJS::ProgramError: 运行 rake 资产时出现意外的标记 punc «(»,预期的 punc «:»:在生产中预编译 - ExecJS::ProgramError: Unexpected token punc «(», expected punc «:» when running rake assets:precompile on production ExecJS :: ProgramError:意外字符“#” - ExecJS::ProgramError: Unexpected character '#' git:ExecJS :: ProgramError:意外的令牌:推送到生产环境时的名称(jquery) - git: ExecJS::ProgramError: Unexpected token: name (jquery) when push to production environment Heroku ExecJS :: ProgramError:意外令牌:错误导轨 - Heroku ExecJS::ProgramError: Unexpected token: error rails Heroku红宝石Rails 4与heroku ExecJS :: ProgramError:意外令牌:错误 - Heroku ruby rails 4 with heroku ExecJS::ProgramError: Unexpected token: error ExecJS :: ProgramError:SyntaxError:保留字“function” - ExecJS::ProgramError: SyntaxError: Reserved word “function” 将Rails应用程序部署到Heroku时出现语法错误:ExecJS :: RuntimeError:SyntaxError:Unexpected character - Syntax error when deploying Rails app to Heroku: ExecJS::RuntimeError: SyntaxError: Unexpected character 不预编译某些资产 - Rails - Not precompile on certain assets - Rails 我在Posts#index中收到以下错误ExecJS :: ProgramError如何解决此问题? - I get the following error ExecJS::ProgramError in Posts#index How do I fix this? 未定义方法预编译资产错误 - Precompile Assets Error By Undefined Method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM