使用Mac上的Visual Studio代码调试电子

Sit*_*kar 2 debugging macos electron

请参阅此stackoverflow问题:

我试图在Mac上做同样的事情.我和上面一样,除了代替

"runtimeExecutable":"node_modules/electron-prebuilt/dist/electron.exe"我把它作为

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

electron --debug-brk=5858 .
Run Code Online (Sandbox Code Playgroud)

我的程序启动并运行没有破坏.

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

[
    { "key": "shift+ctrl+f5", "command": "workbench.action.debug.play",
                                     "when": "inDebugMode" },
    { "key": "shift+ctrl+f5", "command": "workbench.action.debug.start",
                                     "when": "!inDebugMode" },
]
Run Code Online (Sandbox Code Playgroud)

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

我收到以下错误:

错误:连接失败

当我运行节点而不是电子时,调试器在从命令行启动应用程序时工作正常

请帮忙!

提前致谢

Jos*_*ler 6

这是你的launch.json.重要的部分是runtimeExecutable和env.对于VS Code 0.8.0,调试仅主要使用电子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
            }
        ]
    }
Run Code Online (Sandbox Code Playgroud)

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