Debugging CoffeeScript line-by-line

DebuggingCoffeescript

Debugging Problem Overview


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.

Debugging Solutions


Solution 1 - Debugging

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.

Solution 2 - Debugging

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

Solution 3 - Debugging

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

Solution 4 - Debugging

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.

Solution 5 - Debugging

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/

Solution 6 - Debugging

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
		]
	}]
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChris DutrowView Question on Stackoverflow
Solution 1 - DebuggingMiguel PingView Answer on Stackoverflow
Solution 2 - DebuggingLloydView Answer on Stackoverflow
Solution 3 - DebuggingleonmView Answer on Stackoverflow
Solution 4 - DebuggingsrusView Answer on Stackoverflow
Solution 5 - DebugginglhkView Answer on Stackoverflow
Solution 6 - Debuggingdefend orcaView Answer on Stackoverflow