ExecJS咖啡脚本不显示编译错误的行号(Rails资产管道) [英] ExecJS coffee script not showing line numbers for compile errors (Rails asset pipeline)

查看:235
本文介绍了ExecJS咖啡脚本不显示编译错误的行号(Rails资产管道)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个Rails应用程序中,ExecJS不显示coffeescript编译错误的行号。我的编译错误信息将如下所示:

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::RuntimeError in Referrals#new

Showing ~/MyApp/app/views/layouts/application.html.erb where line #6 raised:

SyntaxError: unexpected IDENTIFIER
  (in ~/MyApp/assets/javascripts/utils.js.coffee)

请注意,咖啡脚本源没有行号(第6行是erb文件)。

Note that there's no line number for the coffee script source (line #6 is for the erb file).

在我的另一个应用程序,我仍然得到行号,语法错误看起来像这样:

On another one of my apps, where I'm still getting the line numbers, a syntax error looks like this:

ExecJS::ProgramError in Projects#show

Showing ~/OtherApp/app/views/layouts/application.html.erb where     line #17 raised:

Error: Parse error on line 6: Unexpected 'STRING'
(in ~/OtherApp/app/assets/javascripts/projects.js.coffee)



<将给我的行号,其中 ExecJS :: RuntimeError 不会。

任何人都有任何想法如何得到行号吗?为什么我的应用程序创建RuntimeErrors对咖啡资产编译,而另一个是给程序错误?我已经检查了Rails,它们似乎匹配。

Anyone have any idea how to get the line numbers back? Why is my app creating RuntimeErrors on coffee asset compilation, while the other is giving ProgramErrors? I've checked Rails and they seem to match.

请注意,如果我修复编译错误,应用程序运行良好(例如,咖啡文件实际上是编译)

Note that if I fix the compilation errors, the app runs fine (e.g., the coffee files are actually do get compiled) -- but it'd be nice to have those line numbers point me to the compilation errors!.

EDIT
我可以使用这些行号来指定编译错误。意识到,无论是ExecJS Runtimeerror 还是 ProgramError 似乎并不重要 - 在第一个应用程序,

EDIT I realized that whether it's an ExecJS Runtimeerror or a ProgramError doesn't seem to matter -- in the first app, there's never a line number given and in the second, there always is.

推荐答案

我想出来 - 这是由于 coffee-script-source gem版本。在给出行号的应用程序中, bundle show 提供了1.4.0的咖啡脚本源,而另一个应用程序的咖啡脚本源为1.6。 1。

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.

我没有注意到这是因为 coffee-rails gem没有紧紧指定这个依赖在我的Gemfiles,我使用 gem'coffee-rails','3.2')。 要解决此问题,只需显式指定coffee-script-source gem版本

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'

包更新coffee-script-source

希望这可以帮助任何其他人可能会遇到这种差异。

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

这篇关于ExecJS咖啡脚本不显示编译错误的行号(Rails资产管道)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆