electron-sudo icon indicating copy to clipboard operation
electron-sudo copied to clipboard

Error Uncaught Exception: TypeError: Sudoer is not a constructor

Open duongtungls opened this issue 7 years ago • 2 comments

I use example code on Electron main thread but get back error Uncaught Exception: TypeError: Sudoer is not a constructor

const {Sudoer} = require('electron-sudo')

let options = {name: 'electron sudo application'},
    sudoer = new Sudoer(options);

/* Spawn subprocess behavior */
let cp = await sudoer.spawn(
  'echo', ['$PARAM'], {env: {PARAM: 'VALUE'}}
);
cp.on('close', () => {
  /*
    cp.output.stdout (Buffer)
    cp.output.stderr (Buffer)
  */
});

Please help figure out where is problem. thanks

duongtungls avatar May 14 '18 13:05 duongtungls

require('electron-sudo').default

juleskreutzer avatar Sep 06 '18 11:09 juleskreutzer

I had to use

const Sudoer = require("electron-sudo").default

There was nothing to unpack when using const { Sudoer } = ...

XDGFX avatar Dec 14 '21 16:12 XDGFX