I
I
Insolent Muzzle2020-04-29 11:21:57
JavaScript
Insolent Muzzle, 2020-04-29 11:21:57

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

2 answer(s)
W
Wynell_ru, 2020-04-29
@pluffie

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

A
Air_Sidney, 2021-03-11
@Air_Sidney

Same error on 12 version of electron, nodeIntegration: true doesn't help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question