【发布时间】:2019-07-05 16:59:53
【问题描述】:
我的大多数 node.js 应用程序都是使用 require() 模块化编写的,因此大多数实际程序执行发生在 index.js 文件之外。
我发现在使用node --inspect=0.0.0.0 index.js 时,我只能设置断点并在程序在index.js 中运行时对其进行评估。
如何设置 node.js 调试器(或任何其他方法),以便我可以在调试器中查看属于我的应用程序的特定模块?
我也在使用 Visual Studio Code 进行调试。
我从 docker 容器中运行我的所有应用程序,因此我使用 0.0.0.0 作为地址。
我试过了:
node --inspect=0.0.0.0 index.js
连接到调试器但只看到 index.js
还有:
node index.js --inspect src/core/my_module.js
甚至不启动调试器
然后我使用 Visual Studio 代码连接到调试器,并可以在 index.js 中设置断点。但是,我无法在 index.js 中的任何模块文件上查看或设置断点,例如 const my_module = require('my_module')
我期待有某种方法可以使用 node.js 和 Visual Studio Code 调试完全模块化的应用程序。如何做到这一点?
-感谢您的宝贵时间
【问题讨论】:
标签: node.js debugging visual-studio-code node-inspector