您可以将Node Inspector与.coffee处理程序一起使用吗?

Qix*_*Qix 7 node.js coffeescript node-debugger

如果您使用JavaScript或编译的Coffee()编写脚本,则使用node-inspector调试节点应用程序非常简单coffee -c -m script.coffee.

但是,使用coffeescript require处理程序时:

 require('coffee-script/register');
 require('lib/component.coffee');
Run Code Online (Sandbox Code Playgroud)

在我试图调试使用的脚本中node-debug,我得到:

(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)
  ...
Run Code Online (Sandbox Code Playgroud)

就像我require的文件一样.

我正在尝试做什么?我有我宁愿几个CoffeeScript的文件不会有我想要测试每次编译.

jco*_*lum 10

当然是.我一直使用它,命令行看起来像这样:

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'
Run Code Online (Sandbox Code Playgroud)

我刚检查了最后一行,它正在工作,并且有coffeescript要求.然而,当我调试时,我实际上看到的是javascript,而不是咖啡.我不知道是否可以使用node-inspector运行和调试coffeescript(编辑:是的,是的,需要使用源映射,但这超出了这个答案的范围).我不相信它有价值 - 我认为能够很好地阅读javascript很好,所以我没有调查过它.

我认为您的问题可能在编译中,您是否尝试编译所需的文件?

  • 工作就像一个魅力.谢谢! (2认同)