具有管理权限的电子子进程,在必要时向用户显示操作系统对话框。
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
};暂无开放 Issues,或尚未同步最近议题。