electron setup code example
Example 1: electron quickstart guide
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('index.html')
win.webContents.openDevTools()
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
Example 2: electron setup cmd
1) Make sure node.js is installed on your machine
2) CD into your directory
3) Crete a json package using the following command:
npm init
4) Install the electron module using the following command:
npm install --save-dev electron
Example 3: install electron
npm install electron --save-dev
Copy
Example 4: electron quickstart guide
mkdir my-electron-app && cd my-electron-app
npm init -y
npm i --save-dev electron
Example 5: js electron setup
npm install electron --save-devCopy