So, I am writing an application with the node/express + jade combo.
I have client.js
, which is loaded on the client. In that file I have code that calls
I am coming from an electron environment, where I need IPC communication between a renderer process and the main process. The renderer process sits in an HTML file between script tags and generates the same error. The line
const {ipcRenderer} = require('electron')
throws the Uncaught ReferenceError: require is not defined
I was able to work around that by specifying node integration as true when the browser window (where this HTML file is embedded) was originally created in the main process.
function createAddItemWindow() {
//Create new window
addItemWindown = new BrowserWindow({
width: 300,
height: 200,
title: 'Add Item',
//The lines below solved the issue
webPreferences: {
nodeIntegration: true
}
})}
That solved the issue for me. The solution was proposed here. Hopes this helps someone else. Cheers.