Debug/dev mode


#1

Currently I have a flag in my app that I can set to true/false depending on if I want to enable developer or debug mode.

This works, but just wondering if there is some native electron/nodejs way to enable (and check for) a debug mode?

Is it also possible using native methods to start debug mode while the app is already running? (e.g. click a menu item to enable debug mode, which shows developer menu items etc)


#2

The webContents.toggleDevTools() method can achieve that and there’s an example of it being called (in a dropdown menu item like in Atom) here.


#3

The most common way is setting an environment variable called NODE_ENV to either "development" or "production" and reading it while your app is still booting.


#4

You can also check electron-is-dev package written from the community.