当运行node debug file.js
时,您应该能够调用list
来显示执行行及其周围的行。当我这样做时,我得到的只是 [Function]
,这是为什么?
debug> list
[Function]
这是我刚刚尝试调试的示例文件:
const h = require('virtual-dom/h');
const toHTML = require('vdom-to-html');
var tree = h('input', { type: 'submit', value: 'Add' });
var str = toHTML(tree);
无论我在哪里尝试“列出”,它都会显示[Function]
。
最佳答案
list
是调试器中的一个函数。它打印出 [function]
的原因是因为您没有调用它,而是导致 repl 返回 list
函数。
您需要调用list()
。
例如
> node debug logger.js
< Debugger listening on port 5858
connecting to port 5858... ok
break in logger.js:1
> 1 'use strict';
2
3 const bunyan = require('bunyan');
debug> list()
> 1 'use strict';
2
3 const bunyan = require('bunyan');
4
5 /**
6 * Returns a configured bunyan logger
debug> list
[Function]
debug>
关于node.js - Node.js 调试器上的 List 命令仅返回 [Function],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28973423/