Can you use Node Inspector with a handler. Coffee?

Debugging node applications using node-inspector is pretty simple if you use scripts using JavaScript or compiled coffee ( coffee -c -m script.coffee ).

However, when using the coffeescript require handler:

  require('coffee-script/register'); require('lib/component.coffee'); 

in script I'm trying to debug using node-debug , I get:

 (function (exports, require, module, __filename, __dirname) { # ^ SyntaxError: Unexpected token ILLEGAL at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) ... 

as i require file.

Am I trying to do this? I have several CoffeeScript files that I really would not like to compile every time I want to test.

+7
coffeescript node-debugger
source share
1 answer

Yes, definitely. I use it all the time, the command line looks like this:

 node-inspector & coffee --nodejs --debug-brk ./scripts/mongoEtl.coffee node-inspector & mocha --compilers coffee:coffee-script ./test/dataLayer-test.coffee --ui bdd --debug-brk node-inspector --web-port=5870 & mocha --compilers coffee:coffee-script/register ./test/dataLayer-test.coffee --ui bdd --debug-brk=5880 -g 'my test name here' 

I just checked the last line, it works and requires coffeescript. However, when I debug, I actually see javascript, not coffee. I don’t know if it is possible to run and debug coffeescript using the node -inpector (editing: yes, it is, it requires the use of source maps, but this is not available for this answer). I'm not sure what is of value - I find it good to read javascript, so I have not studied it.

I think that your problem may be in compilation, have you tried to compile the required file?

+10
source share

All Articles