ReferenceError: require is not defined
nodeIntegration의 기본 값이 false로 되어있기 때문에 이를 true로 만들어주면 해결된다.
app.on('ready', () => {
var path = app.getAppPath()
console.log(__dirname)
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});
mainWindow.loadURL(`file://${app.getAppPath()}/index.html`);
mainWindow.on('closed', () => { mainWindow = null; });
});
출처:
https://stackoverflow.com/questions/44391448/electron-require-is-not-defined