I am creating an electron app where I need to scan and update files which need root permission. I know I can run such commands using sudo.exec() in that way:
You need to run the applicaton with administrator privilege.
If you are using electron builder to build the app, use the requestedExecutionLevel value as "requireAdministrator"