ExecJS coffee script not showing line numbers for compile errors (Rails asset pipeline)

前端 未结 2 1667
青春惊慌失措
青春惊慌失措 2021-02-05 17:49

In one of my Rails apps, ExecJS is not showing line numbers for coffeescript compilation errors. My compile error message will look like this:

ExecJS::RuntimeErr         


        
相关标签:
2条回答
  • 2021-02-05 18:07

    I figured it out -- it's due to the coffee-script-source gem version. In the app that was giving line numbers, bundle show gives coffee-script-source of 1.4.0, whereas the other app had a coffee-script-source version of 1.6.1.

    I didn't notice this because the coffee-rails gem doesn't tightly specify this dependency (in both my Gemfiles, I was using gem 'coffee-rails', '3.2'). To get around this, just explicitly specify the coffee-script-source gem version:

    gem 'coffee-rails', '3.2.2'
    gem 'coffee-script-source', '1.5.0'
    

    and bundle update coffee-script-source.

    Hopefully this helps anyone else who might run into this discrepancy.

    0 讨论(0)
  • 2021-02-05 18:10

    This can also be fixed with this patch that embeds the line information in the error message for the ruby-coffee-script gem.

    If you're using source maps, this patch fixes the coffee-rails-source-maps gem.

    0 讨论(0)
提交回复
热议问题