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.
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
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.
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/
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
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.
now is 2020, i find this question, and then i find vscode support sourcemap, so we can use vscode to debug coffee directly.
btw, i think coffee need a great improve. just like static data. anyway here is my launch.json:
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}", //important, make sure debug current file
"outFiles": [
"${workspaceFolder}/dist/api/api.js" //important, where to find sourcemap js file
]
}]
}