How to detect that the Electron app is running for the first time?

electron, electron-builder

Solution

Check for the squirrel-firstrun flag:

var cmd = process.argv[1];

if (cmd == '--squirrel-firstrun') {
    // Running for the first time.
}

(you don't need to install anything for this to work)

Ref.

Problem

I'm developing an App using the latest version of Electron-builder (using AutoUpadate). Is there any way to know that the App is running for the first time after installation? Ps: I have tried using electron-config but the user data files are not deleted after uninstall, and I needed to do some things with every installation (even if it's on the same machine).

Original source