Here is my main (index.js) file:
const { app, BrowserWindow } = require("electron")
var mainWindow = null
app.on("ready", () => {
mainWindow = new BrowserWindow({
"width": 500,
"height": 500,
"webPreferences": {
"nodeIntegration": true,
"contextIsolation": false
}
})
mainWindow.loadFile("src/html/welcome.html")
})
Now, I cannot use import/exports.
Whenever I am adding an export statement below the above code, it gives an error saying Uncaught TypeError: Cannot read properties of undefined (reading 'on')
If I remove the export/import lines, it works fine, as expected
(index.js)
const { app, BrowserWindow } = require("electron")
var mainWindow = null
app.on("ready", () => {
mainWindow = new BrowserWindow({
"width": 500,
"height": 500,
"webPreferences": {
"nodeIntegration": true,
"contextIsolation": false
}
})
mainWindow.loadFile("src/html/welcome.html")
})
module.exports.updateFunction = (_name) => {
console.log(_name)
}
another.js
const { updateFunction } = require("../../index");
updateFunction("Hellow")
