简体   繁体   English

对于 React 应用程序,vscode 调试器中的断点通常会失败

[英]Breakpoints in vscode debugger often fail for a React application

My React application is written in Typescript and I debug it using Chrome.我的 React 应用程序是用 Typescript 编写的,我使用 Chrome 对其进行调试。 After a fresh start of the application everything works fine.重新启动应用程序后,一切正常。 I can set breakpoints and the debugger stops at them.我可以设置断点并且调试器在它们处停止。

The problems appear when I change source code.当我更改源代码时出现问题。 Existing breakpoints are moved to a wrong line and when I try to set new breakpoints they cannot be resolved.现有断点移动到错误的行,当我尝试设置新断点时,它们无法解决。 I have to close Chrome and re-open it to make things work again.我必须关闭 Chrome 并重新打开它才能让事情再次正常运行。 My launch config is:我的启动配置是:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Shell GUI",
            "url": "https://localhost:3001",
            "webRoot": "${workspaceFolder}/src",
            "userDataDir": "${workspaceRoot}/.vscode/chrome",
            "sourceMaps": true,
            "sourceMapPathOverrides": {
                "webpack:///build/*": "${webRoot}/*"
            }
        }
    ]
}

I tried to fix the issue by specifying source map overrides, but that has not improved the situation at all.我试图通过指定源 map 覆盖来解决这个问题,但这根本没有改善这种情况。 And if I haven't created a production build yet then there's no build folder at all.如果我还没有创建生产版本,那么根本就没有构建文件夹。 To me it looks as if Chrome doesn't get code changes (assuming here that breakpoints are evaluated by Chrome).在我看来,Chrome 似乎没有进行代码更改(假设此处断点由 Chrome 评估)。

What do I have to change to make debugging working correctly, even after source code changes?即使在源代码更改后,我必须更改什么才能使调试正常工作?

Unfortunately this is a known issue with create-react-app at the moment:不幸的是,目前这是 create-react-app 的一个已知问题:

There's a link to track the issue here: https://github.com/facebook/create-react-app/issues/6074这里有一个跟踪问题的链接: https://github.com/facebook/create-react-app/issues/6074

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM