最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

使用VSCode调试电子锻造应用程序

运维笔记admin14浏览0评论

使用VSCode调试电子锻造应用程序

使用VSCode调试电子锻造应用程序

我正在尝试使用VSCode调试我的电子锻造项目(电子主过程,而不是渲染),但到处都是错误的。我安装了所有依赖项的electron-forge包并初始化我的项目。

我遵循this指令,我的launch.json for VSCode是:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron Main",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd",
            "cwd": "${workspaceRoot}"
        }
    ]
}

但是当我在VSCode中调试F5进行调试时,我得到了Attribute "runtimeExecutable" does not exist因为全局安装了electron-forge所以node_modules/.bin/目录中没有这样的文件。

然后根据this我改变了"runtimeExecutable"和我的launch.json如下:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron Main",
            "runtimeExecutable": "electron-forge-vscode-win.cmd",
            "cwd": "${workspaceRoot}"
        }
    ]
}

命令行是:

electron-forge-vscode-win.cmd --debug-brk=17423 --nolazy 
√ Locating Application
√ Preparing native dependencies
√ Launching Application

但仍然没有发生。我的电子应用程序开始但并未停止,因为--debug-brk论证。

接下来,我在launch.json上添加了一行:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "name": "Electron Main",
            "runtimeExecutable": "electron-forge-vscode-win.cmd",
            "protocol": "inspector"
        }
    ]
}

使用此命令行启动:

electron-forge-vscode-win.cmd --inspect=11172 --debug-brk 
√ Locating Application
√ Preparing native dependencies
√ Launching Application

注意:11172是随机端口号

现在我收到了这个错误:Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:11172)

回答如下:

我相信你需要将"protocol"="legacy"添加到你的启动配置中。这假设您使用的是Node版本<8.x.

发布评论

评论列表(0)

  1. 暂无评论