Debugging CoffeeScript line-by-line

假装没事ソ 提交于 2019-12-20 08:24:04

问题


Is there a way to debug CoffeeScript line-by-line?

I understand that it compiles into Javascript. But this sounds like it could make it a pain to debug.


回答1:


At the moment it is quite a pain to debug CoffeeScript. Most people use lots of unit tests.

There is some work being done on debugging for CoffeeScript but it is probably a while away before we'll have a really good debugger. One example is http://www.infoq.com/news/2011/08/debug-languages-on-javascript-vm




回答2:


Update: there's currently a redesign of coffeescript compiler that generates source maps, which should enable you to debug your coffeescript in most recent versions of Google Chrome (18 and upwards I think).

I think it's not production-ready yet, but it's worth mentioning.




回答3:


if you are running coffeescript from the terminal you can debug it line-for-line using node-inspector, launching your script this way:

coffee --nodejs --debug-brk yourscript.coffee



回答4:


Yes, with node-inspector:

npm install -g node-inspector

By putting the statement debugger into the source code of your script, you will enable a breakpoint. Then type in a console:

coffee -c -m myscript.coffee
node-debug myscript.js

Node Inspector supports source-maps out of the box, so no extra configuration is needed.

For more information see this post.




回答5:


Coffeescript now supports source maps: http://coffeescript.org/

Jetbrains for example supports this feature: https://blog.jetbrains.com/ruby/2013/01/whats-mining-coffeescript-debugger/



来源:https://stackoverflow.com/questions/11068023/debugging-coffeescript-line-by-line

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