const { app, BrowserWindow, dialog } = require('electron') const sharp = require('sharp'); async function createWindow() { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } }); await win.loadFile('index.html'); try { await sharp('test.png').toFile('test.jpg'); } catch (err) { console.error(err.stack); } } app.whenReady().then(createWindow); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } }); app.on('activate', async () => { if (BrowserWindow.getAllWindows().length === 0) { await createWindow() } }); (async () => { try { await sharp('test.png').toFile('test.jpg'); } catch (err) { console.error(err.stack); } })();