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

 玫瑰编辑1轶事 发布于 2022-12-27 16:25

我正在尝试使用以下命令为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 (:2357:10623)
    at js_error (:2357:10842)
    at parse_error (:2357:12560)
    at Object.next_token [as input] (:2357:17582)
    at next (:2357:18881)
    at semicolon (:2357:19726)
    at simple_statement (:2357:22538)
    at :2357:20689
    at :2357:19938
    at :2357:31926
    at Object.parse (: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 (:2357:10842)
at parse_error (:2357:12560)
at next_token (:2357:17582)
at next (:2357:18881)
at semicolon (:2357:19726)
at simple_statement (:2357:22538)
at :2357:20689
at :2357:19938
at :2357:31926
at parse (:2358:98)
at :19:24
at :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)

我尝试使用--traceswitch/option 运行上面提到的命令,但是对于导致此错误的原因我有点无能为力.这个项目可以在这里查看=> https://github.com/ipatch/crj.com

2 个回答
  • 这很可能是因为rails会为您生成一个空的coffescript文件,作为您在项目中生成控制器的一部分.您也可能将coffescript重命名为.js

    在空的js文件中,您将找到自动生成的coffescript注释,该注释以#而不是//由javascript使用.只需删除所有评论,您就可以开始了.

    编辑

    由于在您的示例的第13079行中找到了意外的'#'字符,因此您将在同一行找到您的评论.

    2022-12-27 16:28 回答
  • demo.js是一个JavaScript文件,但使用CoffeeScript comments(#)而不是JavaScript comments(//).

    2022-12-27 16:28 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有