Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么node.js会打印错误的堆栈跟踪?_Javascript_Node.js - Fatal编程技术网

Javascript 为什么node.js会打印错误的堆栈跟踪?

Javascript 为什么node.js会打印错误的堆栈跟踪?,javascript,node.js,Javascript,Node.js,为什么每当创建(而不是抛出)对象时,node.js会在REPL中打印stacktrace?其他REPL在默认情况下似乎没有这种行为,我看不到它的用例 有没有办法抑制这种行为 Python: $ python Python 2.7.11 (default, Jan 22 2016, 08:29:18) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credi

为什么每当创建(而不是抛出)对象时,node.js会在REPL中打印stacktrace?其他REPL在默认情况下似乎没有这种行为,我看不到它的用例

有没有办法抑制这种行为

Python:

$ python
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> Exception('something bad happened')
Exception('something bad happened',)
节点:


这是错误本身的一部分。在REPL中,计算并打印错误。如果执行
var a=newerror(“…”)
操作,则不会显示任何内容。在节点中,还是在windows中。我得到->
>新错误(“发生了不好的事情”)
->
[错误:发生了不好的事情]
这是错误本身的一部分。在REPL中,计算并打印错误。如果执行
var a=newerror(“…”)
操作,则不会显示任何内容。在节点中,还是在windows中。我得到->
>新的错误(“发生了不好的事情”)
->
[错误:发生了不好的事情]
$ node
> new Error('something bad happened')
Error: something bad happened
    at repl:1:1
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:504:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)
new Error('something bad happened')
Error: something bad happened(…)