Exploring the Electron application framework
Porting
You can port the boilerplate app from Figure 2 to other desktop systems using the forge package
command. Without specifying options, the command (under Ubuntu 16.04) creates a standalone version for Linux and the existing x64 processor architecture in the out/app-linux-x64
subdirectory of the app
project folder. In addition to the approximately 80MB executable app
in ELF format, this directory also contains other binary files. You will find the web application and the required node packages under resources/app
. After switching to the directory, the ./app
command starts the app in the shell, which looks exactly like Figure 2.
You can port the app to Windows using the --platform
command-line switch in the forge package --platform win32
command. This command creates the app for 64-bit Windows in the out/app-win32-x64
folder. In addition to the executable app.exe
, the distribution contains a large number of Windows DLLs and the resources
folder, which is more or less bit-identical to the matching folder for Linux.
If you copy the folder from Linux to a Windows 10 system and start the app, you won't see any notable differences with Figure 2. Conversely, you could install electron-forge
under Windows 10, and, in that case, the Linux app created under Windows will run under Linux.
You can assign a processor architecture with the arch
command-line switch. Table 1 shows the possible combinations of values for platform
and arch
.
Table 1
Electron Compatibility
System | Version | IA-32 | x64 | ARMv7l | ARM64 |
---|---|---|---|---|---|
Ubuntu |
>=12.04 |
Yes |
Yes (tested) |
Yes |
Yes |
Debian |
8 |
Yes |
Yes |
Yes |
Yes |
Fedora |
21 |
Yes |
Yes |
Yes |
Yes |
Windows |
>=7 |
Yes |
Yes (tested) |
Yes |
Yes |
OS X |
>=10.9 |
No |
Yes |
No |
Yes |
Packing
forge
offers to create platform-specific package formats or installers to facilitate easy distribution of the app (Table 2). forge make
generates a Debian package for the Boilerplate app. However, the script terminated in our lab while trying to create an RPM package, with the error message from Figure 3. sudo apt-get install rpm
fixed the problem.
Table 2
Possible Package Formats under forge
Type | System | Description |
---|---|---|
zip |
All |
Zip archive |
squirrel |
Windows |
Installer for Squirrel-Dot-Windows |
appx |
Windows |
Windows-Store packet |
dmg |
OS X Darwin |
DMG packet |
deb |
Linux |
Debian packet |
rpm |
Linux |
RPM packet |
flatpack |
Linux |
Flatpack packet |
Similar scenes occurred while trying to create a Windows installer with the forge make --platform win32
command. In this case, .NET support was missing:
sudo apt-get install mono wine
Under out/make/squirell.Windows/x64
, you will find the app-1.0.0 Setup.exe
installer file, which we were able to install on Windows 10 without any problems.
Listing 3 displays the configuration object [11] from the package.json
file as a portal. Lines 2 to 13 contain the package formats to be generated in the make_targets
sub-object, listed by operating system.
Listing 3
Configuration of forge
01 [...] 02 "forge": { 03 "make_targets": { 04 "win32": [ 05 "squirrel" 06 ], 07 "darwin": [ 08 "zip" 09 ], 10 "linux": [ 11 "deb", 12 "rpm" 13 ] 14 }, 15 "electronPackagerConfig": { 16 "packageManager": "yarn" 17 }, 18 "electronWinstallerConfig": { 19 "name": "app" 20 }, 21 "electronInstallerDebian": {}, 22 "electronInstallerRedhat": {}, 23 "github_repository": { 24 "owner": "", 25 "name": "" 26 }, 27 "windowsStoreConfig": { 28 "packageName": "", 29 "name": "app" 30 } 31 } 32 [...]
Conclusions
Electron makes it easy to create desktop apps using popular web technologies such as HTML, CSS, and JavaScript. At the same time, Electron offers an infrastructure that can port apps to other systems via the command line.
Compared to Cordova Phone Gap [12], the installation is trivial, even if support for mobile operating systems such as Android or iOS is currently missing. If you want to be on the safe side, simply pack on the target system each time and test the app immediately.
Infos
- Electron: https://electronjs.org
- Chromium: https://www.chromium.org
- Node.js: https://nodejs.org
- Bootstrap: https://getbootstrap.com
- React: https://reactjs.org
- Angular: https://angular.io
- JQuery: https://jquery.com
- Yarn: https://yarnpkg.com
electron-forge
: https://github.com/electron-userland/electron-forge- Boilerplate projects: https://github.com/sindresorhus/awesome-electron#boilerplates
- Configuration of
electron-forge
: https://github.com/electron-userland/electron-forge#config - Phone Gap: https://phonegap.com
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.