DEV Community

Cover image for Create an Electron app on Fedora
Austin Cunningham
Austin Cunningham

Posted on

7 4

Create an Electron app on Fedora

Creating the Electron App

Wanted to play around with creating a desktop app with Electron on Fedora. Followed the quick start guide for Electron changing the win.loadFile to win.loadURL to load an existing web app. Code is here here is my main.js

const { app, BrowserWindow } = require('electron')
const path = require('path')

const createWindow = () => {
  const win = new BrowserWindow({
    width: 1200,
    height: 850,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

  win.loadURL('https://austincunningham.github.io/Git_Repos_Rest_API/lab-4.1-Github-API/index.html')

}

app.whenReady().then(() => {
  createWindow()

  app.on('activate', function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })

})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})
Enter fullscreen mode Exit fullscreen mode

Testing the app by running npm start and the app opens
Image of the app open
That seems straight forward.

Building the binary

Again following the quick start guide I get to the npm run make command here is where I hit some trouble

npm run make

> electron-github@1.0.0 make /home/austincunningham/repo/electron-github
> electron-forge make

✔ Checking your system
✔ Resolving Forge Config

An unhandled rejection has occurred inside Forge:
Error: Cannot make for deb, the following external binaries need to be installed: dpkg, fakeroot

Electron Forge was terminated. Location:
Enter fullscreen mode Exit fullscreen mode

So I install the missing dependencies

sudo dnf install dpkg
sudo dnf install fakeroot
Enter fullscreen mode Exit fullscreen mode

I rerun the npm run make command

npm run make

> electron-github@1.0.0 make /home/austincunningham/repo/electron-github
> electron-forge make

✔ Checking your system
✔ Resolving Forge Config

An unhandled rejection has occurred inside Forge:
Error: Cannot make for rpm, the following external binaries need to be installed: rpmbuild

Electron Forge was terminated. Location:
Enter fullscreen mode Exit fullscreen mode

So I guess there is another missing dependency I try and install rpmbuild

sudo dnf install rpmbuild
No match for argument: rpmbuild
Error: Unable to find a match: rpmbuild
Enter fullscreen mode Exit fullscreen mode

I figure it rpm related so Googled it and find https://www.redhat.com/sysadmin/create-rpm-package
I install the dependencies from the blog

sudo dnf install -y rpmdevtools rpmlint
Enter fullscreen mode Exit fullscreen mode

And happy days the npm run make completes

npm run make                            

> electron-github@1.0.0 make /home/austincunningham/repo/electron-github
> electron-forge make

✔ Checking your system
✔ Resolving Forge Config
We need to package your application before we can make it
✔ Preparing to Package Application for arch: x64
✔ Preparing native dependencies
✔ Packaging Application
Making for the following targets: deb, rpm
✔ Making for target: deb - On platform: linux - For arch: x64
✔ Making for target: rpm - On platform: linux - For arch: x64
Enter fullscreen mode Exit fullscreen mode

It built the deb and rpm bundles, guessing need to be run on windows and mac to build their binaries. More to learn here but that's all for now.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
ileosebastian profile image
Leo Intriago

This article could not be more necessary. Thank you!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay