【问题标题】:Debug Electron using Visual Studio Code on Mac在 Mac 上使用 Visual Studio Code 调试 Electron
【发布时间】:2015-10-11 20:32:10
【问题描述】:

Refer to this stackoverflow question:

我正在尝试做同样的事情,但在 Mac 上。我和上面一样,除了代替

“runtimeExecutable”:“node_modules/electron-prebuilt/dist/electron.exe” 我有它

"runtimeExecutable": "/usr/local/bin/electron" 由于 mac 上的 F5 映射到屏幕调光器,我从命令行启动应用程序如下:

electron --debug-brk=5858 .

我的程序启动并运行,没有中断。

所以我像这样修改了 keybindings.json:

[
    { "key": "shift+ctrl+f5", "command": "workbench.action.debug.play",
                                     "when": "inDebugMode" },
    { "key": "shift+ctrl+f5", "command": "workbench.action.debug.start",
                                     "when": "!inDebugMode" },
]

我尝试按 shift+ctrl+f5 启动程序 - 我仍然无法调试我的程序。

我收到以下错误:

错误:连接失败

当我运行 node 而不是 electron 时,当应用启动时调试器工作正常命令行

请帮忙!

提前致谢

【问题讨论】:

    标签: macos debugging electron


    【解决方案1】:

    这是你的 launch.json。重要的部分是 runtimeExecutable 和 env。对于 VS Code 0.8.0,调试大多只能使用 electron 0.30.6。

        {
            "version": "0.1.0",
            // List of configurations. Add new configurations or edit existing ones.
            // ONLY "node" and "mono" are supported, change "type" to switch.
            "configurations": [
                {
                    // Name of configuration; appears in the launch configuration drop down menu.
                    "name": "Launch electron",
                    // Type of configuration. Possible values: "node", "mono".
                    "type": "node",
                    // Workspace relative or absolute path to the program.
                    "program": "main.js",
                    // Automatically stop program after launch.
                    "stopOnEntry": false,
                    // Command line arguments passed to the program.
                    "args": [],
                    // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
                    "cwd": ".",
                    // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
                    "runtimeExecutable": "node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/electron",
                    // Optional arguments passed to the runtime executable.
                    "runtimeArgs": [],
                    // Environment variables passed to the program.
                    "env": {"ATOM_SHELL_INTERNAL_RUN_AS_NODE": "0"},
                    // Use JavaScript source maps (if they exist).
                    "sourceMaps": false,
                    // If JavaScript source maps are enabled, the generated code is expected in this directory.
                    "outDir": null
                },
                {
                    "name": "Attach",
                    "type": "node",
                    // TCP/IP address. Default is "localhost".
                    "address": "localhost",
                    // Port to attach to.
                    "port": 5858,
                    "sourceMaps": false
                }
            ]
        }
    

    使用npm install –-save-dev electron-prebuilt@0.30.6在您的项目目录中安装 0.30.6 的 electron-prebuilt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-11
      • 2018-09-08
      相关资源
      最近更新 更多