【问题标题】:SyntaxError: Unexpected token: punc (}) in rails:precompileSyntaxError: Unexpected token: punc (}) in rails:precompile
【发布时间】:2017-11-14 22:56:07
【问题描述】:

我正在尝试部署到我的登台服务器,突然间我收到以下错误

V8::Error: SyntaxError: Unexpected token: punc (})
at js_error (<eval>:3623:12167) 
at croak (<eval>:3623:22038)
at token_error (<eval>:3623:22175)
at unexpected (<eval>:3623:22263)
at <eval>:3623:23996
at <eval>:3623:22954
at <eval>:3624:3759
at parse (<eval>:3624:3999)
at parse (<eval>:3958:22)
at uglifier (<eval>:4003:13)
/var/www/fdsa/fdsa/bundle/ruby/2.3.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:45:in `block in call'

Tasks: TOP => assets:precompile

我已经运行了这个 rails 代码,但一切看起来都很好,我没有收到任何 javascript 文件的错误。

JS_PATH = "app/assets/javascripts/**/*.js"; 
Dir[JS_PATH].each do |file_name|
  puts "\n#{file_name}"
  puts Uglifier.compile(File.read(file_name))
end

https://stackoverflow.com/questions/12574977/rake-assetsprecompile-gives-punc-error/38228770#38228770

【问题讨论】:

  • 只是疯狂的想法,我觉得这与你的 js 文件有关吗?但我的问题是你是否使用 vanilla js?
  • 我使用 angularjs。

标签: ruby-on-rails uglifier


【解决方案1】:

我遇到了同样的错误并找出了原因。这是因为使用旧的 Angular 语法格式从 Angular 中的 json 中查找记录,rails 4 及更高版本已弃用且不支持。

不支持语法:

Json_data.find(item => item.field_name == 'abc'). 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    • 2018-01-07
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多