I'm trying to use the nodemon package in an Electron project but when I try to execute this with nodemon main.js
I catch this error in terminal:
But when I try to execute simply with "npm electron ." this works properly. Why?
The code of main.js
:
const { app, BrowserWindow } = require('electron');
let mainWindow;
createMainWindow = () => {
mainWindow = new BrowserWindow({
width: 1600, height: 900,
webPreferences: {
nodeIntegration: false
}
});
mainWindow.loadFile('./renderer/index.html')
//mainWindow.webContents.openDevTools();
}
app.whenReady().then(createMainWindow);
I've resolved it.
In package.json I changed the "start": "nodemon ./main.js"
to "watch": "nodemon --exec electron ."
and it worked.