0
Greetings.
I am creating a frameless program on Electron (to make a custom frame) and am getting the error Uncaught ReferenceError: require is not defined
.
My tree is next:
- raiz do projeto
| - frame.js
| - main.js
| - src
| - | - index.html
Arquivo . /main.js:
const {app, BrowserWindow} = require('electron');
require('@electron/remote/main').initialize();
function createWindow() {
const window = new BrowserWindow({
width: 450,
height: 450,
frame: false,
icon: __dirname + 'favicon.png',
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextisolation: false
}
});
window.loadFile('src/index.html');
}
app.whenReady().then(createWindow);
File . /frame.js:
const remote = require('@electron/remote');
const currentWindow = remote.getCurrentWindow();
file . /src/index.html:
<!DOCTYPE html>
<html lang="pt-br">
<body>
<script src="../frame.js"></script>
</body>
</html>
Sure, I cleared all the rest of my code for easy reading, but the code is available in full in that Github repository.
I’ve tried without the contextIsolation
and tried to set it as much as true
how much as false
.
As for the @electron/remote
, I did the update following this tutorial.
The versions of the modules I’m using:
Windows 7 x64
electron 12.0.0
npm 7.6.2
node 12.18.3
Before I was using Electron 10.x and it was working normally.
Thanks for your help.