简体   繁体   English

如何获取Coffeescript文件中错误的行号

[英]how I can get line number with error in coffeescript file

In node.js express app and nodeunit tests I widely use coffeescript without saving resulting javascript files on disk to avoid project clogging by javascript translations. node.js express应用程序和nodeunit测试中,我广泛使用coffeescript而不将生成的javascript文件保存在磁盘上,以避免由于javascript翻译而导致项目阻塞

When I got any error in coffeeScript file I see in console: the filename where error was occured and line number (for example 37): /pathTo_File/fileName.coffee:37 . 当我在coffeeScript文件中遇到任何错误时,我会在控制台中看到:发生错误的文件名和行号(例如37):/ /pathTo_File/fileName.coffee:37 :37。 But I dont have 37th line in my coffee file!!! 但是我的咖啡档案中没有第37行!!! I have two times less lines there. 我那里的台词少了两倍。

I guess that I got error on 37th row in my output javascript file, but I don't have it on disk. 我想我的输出javascript文件中的第37行有错误,但是我没有在磁盘上。 Coffeescript files only. 仅Coffeescript文件。

So how I can get line number with error in coffeescript file ? 那么如何在coffeescript文件中获取错误的行号呢?

I understand that I can translate my coffee script file manually (using console) to js and see there line number and guess on what line I got that error on my coffee file. 我知道我可以手动(使用控制台)将我的咖啡脚本文件转换为js,然后查看行号,并猜测我在咖啡文件上遇到此错误的行。 But maybe there is something faster . 但是也许有更快的东西

My IDE is WebStorm and os is osX. 我的IDE是WebStorm,而os是osX。

CoffeeScript 1.6.1 and above include support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. CoffeeScript 1.6.1及更高版本支持生成源映射,这是一种告诉JavaScript引擎CoffeeScript程序的哪一部分与正在评估的代码相匹配的方法。 Browsers that support it can automatically use source maps to show your original source code in the debugger. 支持它的浏览器可以自动使用源映射在调试器中显示您的原始源代码。 To generate source maps alongside your JavaScript files, pass the --map or -m flag to the compiler. 要在JavaScript文件旁边生成源地图,请将--map或-m标志传递给编译器。

http://coffeescript.org/#source-maps http://coffeescript.org/#source-maps

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM