Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在调试 node.js 应用程序时运气不好。问题是我需要在启动时未加载的文件中设置断点(当 --debug-blk 时)。该文件是来自节点本身的 http.js。
所以我想修改文件以添加调试器;声明,但我无法在我的磁盘上找到这个 http.js 文件?我在磁盘上看到它的唯一地方是节点的源代码分发(lib/http.js)。在 node-src 中进行 make install 后,此文件位于何处,如何在其中设置断点?
http.js 在节点可执行文件内部。它在磁盘上不存在,修改它的唯一方法是从源代码构建节点。
做这个:
var http = require('http'); debugger; // the rest of your app
您的应用程序将启动、加载 http,然后暂停。现在您可以使用检查器在 http 中设置断点。(您不需要--debug-brk,因为该debugger语句会在任何事情真正发生之前暂停应用程序。)
--debug-brk
debugger