• 首页
  • 关于
    • 前端行知录 photo

      前端行知录

      前端路漫漫,行知方知行

    • Email
    • Github
  • 文章
    • 所有文章
    • 所有标签
  • 作品

使用 VSCode 调试基于 ES6 的 electron 主进程

22 Jan 2017

Reading time ~1 minute

使用 VSCode 调试 electron 主进程

1. 在 VSCode 中打开一个 Electron 工程。

$ git clone https://github.com/alcat2008/electron-react-starter.git
$ code electron-react-starter

2. 添加一个文件 .vscode/launch.json 并使用一下配置:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Main Process",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
      "program": "${workspaceRoot}/src/main.development.js",
      "runtimeArgs": [
          "-r",
          "babel-register",
          "-r",
          "babel-polyfill"
      ],
      "env": {
          "HOT": "1",
          "NODE_ENV": "development"
      },
    }
  ]
}

注意: 在 Windows 中,runtimeExecutable 的参数是 "${workspaceRoot}/node_modules/.bin/electron.cmd"。

3. 调试

在 main.development.js 设置断点, 并在 Debug View 中启动调试。你应该能够捕获断点信息。

参考文章

  • 使用 VSCode 进行主进程调试
  • vscode debug ES6 application
Electron

alcat2008

Dreamer, Practitioner, Incomplete Front-ender

← 前端测试框架概览 RHEL 6.5 安装 gcc... →