Answer the question
In order to leave comments, you need to log in
Electron says "Require is not defined". What to do?
I was writing a program on electron and ran into the following error: "Uncaught ReferenceError: require is not defined"
Files render.js:1
and terminal.js:1 are to blame.
I don't understand how to fix it. Help.
UPD: I don't write on email anymore, but others got this error when they switched to version 12. I marked the solution for version 12.
let remote = require('electron').remote;
var spawn = require('child_process').spawn;
Answer the question
In order to leave comments, you need to log in
I will not assign anything to myself, it seems to me that the answer to this question is
already https
:
//stackoverflow.com/questions/44391448/elect ...
You can enable it when creating the BrowserWindow :
app.on('ready', () => {
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
});
Same error on 12 version of electron, nodeIntegration: true doesn't help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question