keybraker / python-gui-electron

A simple example on how to create electron GUIs for python programs
385 stars 41 forks source link

Uncaught ReferenceError: require is not defined #8

Closed datavectors closed 3 years ago

datavectors commented 5 years ago

I ran npm start and window was launched but links did not work. Inspecting View > Toggle Developer Tools I read this error .. Uncaught ReferenceError: require is not defined

Further digging around unearthed this explanation ..

stackoverflow forum

I modified main.js to add under var ui = new BrowserWindow({

webPreferences: {
nodeIntegration: true
 },

And after npm start no errors.

czoka commented 5 years ago

That solved it for me too 😀 I'm so glad that I postponed my tests with this repo. With my almost non-existent electron experience I wouldn't have figured that out. Thanks.

PS: You might want to create a pull request for that.

beliaev-maksim commented 4 years ago

indeed this fixes but author blocks new branches

keybraker commented 3 years ago

I am working on an update as the example was made on version 1 and we are now at 11. What you propose is indeed a solution, but one that is prone to remote native code execution attacks. There is a new way to implement you inclusion of javascript application, which is as follows:

webPreferences: {
    preload: path.join(__dirname, 'gui_example.js'),
    contextIsolation: true
}
jurkov commented 3 years ago

I get the same error with electron 13.

dylanriley31 commented 2 years ago

I am also getting that error.