electron-windows-autoupdate
electron-windows-autoupdate copied to clipboard
Uncaught ReferenceError: require is not defined
Hi. i coped your index.html to my own index.html when trying to run electron app it says :
Uncaught ReferenceError: require is not defined
heh, looks like you launch index.html in classical browser, not via electron.
you got to use npm start
script to run Electron which is a browser wrapped in C++, which has bridge to Node.js inside.
No.i add your code to my index.html then build my app from npm. then make pack of my electron app then run electron app.
i have
mainWindow.webContents.openDevTools();
to see what happens behind.there is console error which says :
Uncaught ReferenceError: require is not defined
Maybe you did not allow node.js in the browser window, that's the only idea I have.
enable nodeIntergration when creating the window
app.on('ready', () => {
console.log('Hello from Electron.');
mainWindow = new BrowserWindow({webPreferences: {
nodeIntegration: true
}});
mainWindow.webContents.loadFile(path.join(__dirname,"index.html"));
mainWindow.webContents.openDevTools();
});
yup, good point @sathiraumesh