1const { app, BrowserWindow } = require('electron')
2
3function createWindow () {
4 const win = new BrowserWindow({
5 width: 800,
6 height: 600,
7 webPreferences: {
8 nodeIntegration: true
9 }
10 })
11
12 win.loadFile('index.html')
13 win.webContents.openDevTools()
14}
15
16app.whenReady().then(createWindow)
17
18app.on('window-all-closed', () => {
19 if (process.platform !== 'darwin') {
20 app.quit()
21 }
22})
23
24app.on('activate', () => {
25 if (BrowserWindow.getAllWindows().length === 0) {
26 createWindow()
27 }
28})
1mkdir my-electron-app && cd my-electron-app
2npm init -y
3npm i --save-dev electron
4