automation-stack / electron-sudo

Electron subprocesses with administrative privileges, prompting the user with an OS dialog if necessary.
MIT License
382 stars 55 forks source link

Cannot find module `regenerator-runtime` #33

Open facekapow opened 7 years ago

facekapow commented 7 years ago

When trying to run an Electron app that uses this, it complains about not being able to find regenerator-runtime. Inspecting the code of dist/index.js reveals that this is true, regenerator-runtime is required but not depended upon.

Ok, that's fine, I just installed regenerator-runtime manually. Except, now it's throwing because it can't read Math from null. Once again, inspecting dist/index.js shows that it's trying to get Math from a window global. I'm trying to use electron-sudo in the main process, is this it only supposed to be used in the renderer process?

facekapow commented 7 years ago

Nevermind, it was my fault, I had some dead code that was settings global.window to null.

facekapow commented 7 years ago

However, on fresh installs, regenerator-runtime isn't depended upon, so that's still an issue.

automation-stack commented 7 years ago

@facekapow regenerator-runtime is a devDependency, from package babel-plugin-transform-regenerator, it's added in appropriate package.json section

facekapow commented 7 years ago

It's required at runtime, it should be a regular dependency; npm doesn't install devDependencies when you do npm install <pkg>.

automation-stack commented 7 years ago

@facekapow regenerator-runtime not correctly packed with webpack, need to investigate it

automation-stack commented 7 years ago

@facekapow https://github.com/automation-stack/electron-sudo/commit/24544fee74e5eb9c97495d6ff81aad5910356ac3

littletinman commented 7 years ago

I'm having this issue using Vanilla Javascript implementation.

Version: 4.0.12 Electron Version: 1.6.11

var Sudoer = require('electron-sudo').default;
var sudoer = new Sudoer();
automation-stack commented 7 years ago

@littletinman did you run npm i in your project directory? babel-runtime now is bundled as dependency

littletinman commented 7 years ago

@automation-stack I ran npm i but nothing was shown, I ended up just running npm install regenerator-runtime --save and that solved the problem.

wle8300 commented 7 years ago

I had this problem. I'm using a Mac so I had to open another tab in Terminal.app. You can just restart Terminal to be doubly sure.

luscas commented 5 years ago
$ rm -rf /node_modules .package-lock.json
$ npm install
gs3bopar commented 3 years ago

When using npm install --save-dev @babel/plugin-transform-runtime, you need to have npm install --save @babel/runtime as a production dependency.

If this doesn't work for you try clearing the npm cache and then do npm install. See if that fixes your problem.

For more information look here: https://babeljs.io/docs/en/babel-plugin-transform-runtime