Electron subprocesses with administrative privileges, prompting the user with an OS dialog if necessary.
Electron subprocesses with administrative privileges, prompting the user with an OS dialog if necessary.
Run a subprocess with administrative privileges, prompting the user with a graphical OS dialog if necessary. Useful for background subprocesse which run native Electron apps that need sudo.
Windows, uses elevate utility with native User Account Control (UAC) prompt (no PowerShell required)OS X, uses bundled applet (inspired by Joran Dirk Greef)Linux, uses system pkexec or gksudo (system or bundled).If you don't trust binaries bundled in npm package you can manually build tools and use them instead.
spawn and exec subprocess behaviorasar archivesh or bat script for single prompt)npm install electron-sudoNote: Your command should not start with the sudo prefix.
……npm i && npm testWebpack config should contain __dirname equals true for work properly
let nodeModules = fs.readdirSync('./node_modules')
.filter((module) => {
return module !== '.bin';
})
.reduce((prev, module) => {
return Object.assign(prev, {[module]: 'commonjs ' + module});
}, {});
export default {
...
target: 'electron',
node: {
/* http://webpack.github.io/docs/configuration.html#node */
__dirname: true
},
externals: nodeModules
};No open issues yet, or sync has not completed.