how I can get line number with error in coffeescript file

笑着哭i 提交于 2019-12-13 04:31:49

问题


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.

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. But I dont have 37th line in my coffee file!!! 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. Coffeescript files only.

So how I can get line number with error in coffeescript file?

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. But maybe there is something faster.

My IDE is WebStorm and os is osX.


回答1:


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. 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.

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



来源:https://stackoverflow.com/questions/17311579/how-i-can-get-line-number-with-error-in-coffeescript-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!