NodeJ:Chrome检查器可以映射源,但无法在原始源上进行调试 [英] NodeJs: Chrome inspector can map source but unable to debug on original source

查看:56
本文介绍了NodeJ:Chrome检查器可以映射源,但无法在原始源上进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将chrome inspector附加到NodeJS进程,发现Chrome可以检测到正在运行的内置源代码(/dist文件夹),并且还可以将源代码(/src文件夹)正确映射到内置源代码

但是,每当我在原始源代码(/src)中放置一个调试点时,该调试点就会在内置(/dist)版本中设置为正确的行,而我只能使用内置版本来调试,但是不是原始的源代码

情况可以在图片中看到我做错什么了吗?这是对

解决方案

这似乎是来自babel的越野车异步源地图.我们必须将@ babel/core从7.9.0版本升级到7.13,并将这两个部分也添加到.babelrc

 "presets":[["@ babel/preset-env",{目标":{节点":true}}]],"retainLines":是, 

I have attached chrome inspector to a NodeJS process and see that Chrome can detect the running built source code ( /dist folder ) and also correctly mapped the source code ( /src folder ) to the built source code

However, Whenever I put a debug point in the original source code (/src) , the debugging point is set to the correct line in the built (/dist) version instead and I can only debug the with the built version but not the original source code

The situation can be seen in the picture Did I do something wrong? This is a follow up to the previous question which involve VS Code Debugger, in the case of VS Code, they can not even detect the original source or sourcemap!

解决方案

This seem to be buggy async sourcemap from babel. We had to upgrade @babel/core from version 7.9.0 to 7.13 and add these 2 parts also into .babelrc

  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "node": true
        }
      }
    ]
  ],
  "retainLines": true,

这篇关于NodeJ:Chrome检查器可以映射源,但无法在原始源上进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆