How to debug electron production binaries

前端 未结 6 1307
一个人的身影
一个人的身影 2021-02-02 11:44

I can\'t open devtools in the built version of my electron app. Therefore i want to find another solution to log any errors that only occur in the production version.

Is

6条回答
  •  清歌不尽
    2021-02-02 11:53

    Enabling the Chrome devtools in production can be done in various ways:

    1. A environment variable:
      • E.g. under Windows set ELECTRON_ENV=development&& myapp.exe
    2. Pass a special parameter to your app
      • E.g. myapp.exe --debug
    3. Debug mode via user settings (if you have persistent settings)
    4. Menu entry to open the devtools
      • Can be combined with 1.-3. to only have that menu entry when in debug mode

    You can just check if 1.-3. are set and if they are, you simply open the devtools via mainWindow.webContents.openDevTools()

    Personally I use a combination of 1., 3. and 4. I simply unlock a developer menu that allows me to open the devtools or opens the userdata folder for me.


    If you also want to log critical errors, then electron-log looks like a rather popular option for electron.

提交回复
热议问题