Reputation: 25
I am trying to make a new Electron desktop app. by the way, when I insert electron module, I get this error. If you are familiar with electron, can you help me to resolve this error?
I already tried to fix it. include require.js. but not working yet.
<script>
const electron = require('electron'); // I get error at this line.
const {ipcRenderer} = electron;
const form = document.querySelector('form');
form.addEventListener('submit', submitForm);
function submitForm(e) {
e.preventDefault();
}
</script>
Upvotes: 2
Views: 597
Reputation: 18537
If you are using Electron
5.0, then nodeIntegration is false by default in BrowserWindows
so you need to specify it explicitly when you create your window:
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
Upvotes: 1
Reputation: 3580
You need to install electron
npm install electron --save-dev
--save-dev
because electron is an development dependency.
Upvotes: 0