首页 文章

如何调试电子伪造反应打字机的渲染过程?

提问于
浏览
1

我使用电子伪造来生成一个基于react-typescript模板的应用程序 . 我为该应用程序编写了一些vscode调试配置 . 但我只能调试Main进程,Renderer丢失了 . 我已经为chrome扩展安装了调试器并在之前使用过它 . 我想知道配置中缺少什么?

{
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron: Main",
            "protocol": "inspector",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win",
            "runtimeArgs": [
                "--remote-debugging-port=9223",
                "."
            ],
            "windows": {
                "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win.cmd"
            }
        },
        {
            "name": "Electron: Renderer",
            "type": "chrome",
            "request": "attach",
            "port": 9223,
            "webRoot": "${workspaceFolder}",
            "timeout": 30000
        }
    ],
    "compounds": [
        {
            "name": "Electron: All",
            "configurations": [
                "Electron: Main",
                "Electron: Renderer"
            ]
        }
    ]
}

1 回答

  • 0

    复制你的 launch.json ,然后编写一些代码并设置断点 . 测试代码放在 app.tsx 的末尾:

    setTimeout(() => {
        let x = 0;            //break point here
        console.log(x);
    }, 3000);
    

    断点工作正常 .

    我在 launch.json 做的另一个改变是:

    "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win",
    "runtimeArgs": [
        ".",  //swap this line and the next line
        "--remote-debugging-port=9223"
    ]
    

相关问题