代码之家  ›  专栏  ›  技术社区  ›  kemakino

用VSCode调试电子渲染器进程

  •  2
  • kemakino  · 技术社区  · 7 年前

    我试过了 this document

    “1.将renderer.js的内容更新为” 在里面 “调试呈现程序进程”
    但当我尝试 ,VSCode显示如下图像,我无法将调试器附加到Electron进程。

    图中的列表显示了浏览器的选项卡,但没有与主调试器启动的电子进程相对应的选项。
    如何解决这个问题?

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  4
  •   noseratio    7 年前

    renderer.js

    async function main() {
      const { ipcRenderer, remote } = require('electron');
      const isDevelopment = require('electron-is-dev');
    
      console.log(process.env);
    
      if (isDevelopment) {
        // this is to give Chrome Debugger time to attach to the new window 
        await new Promise(r => setTimeout(r, 1000));
      }
    
      // breakpoints should work from here on,
      // toggle them with F9 or just use 'debugger'
      debugger;
    
      // ...
    }
    
    main().catch(function (error) {
      console.log(error);
      alert(error);
    });
    

    我有 a customized version 属于 最小电子应用 它解决了这个问题和我开始用电子开发时遇到的其他一些问题。