Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

electron-sudo

> 编程语言
Open source

Electron subprocesses with administrative privileges, prompting the user with an OS dialog if necessary.

387 stars0 likes1 views
WebsiteGitHub

About

Electron subprocesses with administrative privileges, prompting the user with an OS dialog if necessary.

Electron subprocess with administrative privileges

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.

Features

  • Supports spawn and exec subprocess behavior
  • Supports applications packaged as asar archive
  • Separate password prompt for each call (use sh or bat script for single prompt)
  • No external dependencies, does not depend on OS versions

Installation

bash
npm install electron-sudo

Usage

Note: Your command should not start with the sudo prefix.

Version 4.0.*

…

Version 3.0.* (deprecated)

…

Tests

bash
npm i && npm test

Usage with Webpack

Webpack config should contain __dirname equals true for work properly

javascript

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
};

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptelectronelevateprivilegesprompt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言