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

Cannot find module `regenerator-runtime`

Open facekapow opened this issue 8 years ago • 12 comments

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 avatar Nov 04 '16 01:11 facekapow

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

facekapow avatar Nov 04 '16 11:11 facekapow

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

facekapow avatar Nov 04 '16 11:11 facekapow

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

automation-stack avatar Nov 04 '16 11:11 automation-stack

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

facekapow avatar Nov 04 '16 11:11 facekapow

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

automation-stack avatar Nov 04 '16 13:11 automation-stack

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

automation-stack avatar Nov 04 '16 14:11 automation-stack

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();

littletinman avatar Jul 13 '17 14:07 littletinman

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

automation-stack avatar Jul 13 '17 15:07 automation-stack

@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.

littletinman avatar Jul 13 '17 15:07 littletinman

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.

wle8300 avatar Aug 21 '17 04:08 wle8300

$ rm -rf /node_modules .package-lock.json
$ npm install

luscas avatar Feb 02 '19 04:02 luscas

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

gs3bopar avatar Apr 15 '21 17:04 gs3bopar