VSCode 调试 Node.js 核心模块源码

Launch Program 后面是自己的项目目录
在这里插入图片描述
然后点击右边的小齿轮, 进入 launch.json, 配置如下

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Program",
      "program": "${file}/",
      "request": "launch",
      "skipFiles": [
        // "<node_internals>/**"
      ],
      "type": "node",
    }
  ]
}

⭐️ 在 skipFiles 中注释 <node_internals>/**

参数 Debugging in Visual Studio Code 官方文档有解释

  • program - executable or file to run when launching the debugger

在这里插入图片描述

  • ${workspaceFolder} gives the root path of a workspace folder

  • ${file} the file open in the active editor

${file} 打开当前编辑器, 也就是执行当前编辑器打开的文件


代码测试

a.js

require('./b.js')

console.log(require)

在这里插入图片描述

在这里插入图片描述
该四个作用依次如下

  • Resume: 执行到下一个断点
  • Step Over: 执行下一语句
  • Step Into: 执行下一语句,如遇到函数,则进入函数执行
  • Step Out: 跳出当前函数

在这里插入图片描述
这时, 我们看到, 已经进入到 require 函数内部了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值