gpt4 book ai didi

node.js - 是否可以调试 Node 内部模块?

转载 作者:太空宇宙 更新时间:2023-11-03 22:05:02 25 4
gpt4 key购买 nike

例如,我想在内部文件_http_server.js上添加一些断点,但该文件实际上并不存在于我的磁盘上。

我应该做什么?

最佳答案

是的,在编译时,源代码中的 .js 文件被打包到 node 可执行文件中,这让我不确定是否/如何设置断点那里。

什么对我有用:

  1. 将相关的 .js 文件从 Node 源代码的 checkout 复制到当前目录,例如 readline.js
  2. 将本地导入从 require('readline') 更改为 require('./readline')
  3. 使用未记录的 node --expose-internals标记以允许复制的 .js 文件仍然 require('internal/...')
  4. 在当前本地文件上使用 console.log 语句/调试器来了解发生了什么

关于node.js - 是否可以调试 Node 内部模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56436540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com