- Electron Projects
- Denys Vuika
- 326字
- 2021-06-24 12:14:34
Packaging for Ubuntu
The process of packaging your application for Ubuntu doesn't differ much from that of macOS. Let's get started:
- You need to provide an application identifier and a category in the linux section of the package.json file:
{
"build": {
"appId": "com.my.app.id",
"linux": {
"category": "Utility"
}
}
}
Please note that you can declare settings for Linux alongside those for other platforms, which is handy when you're developing for multiple operating systems or switching between them. The same applies to the scripts section. In this book, we are going to use different script names so that you can merge them into a single configuration.
- Update your package.json file and append the following scripts to it so that you can build your application in development mode and distribution mode:
{
"scripts": {
"start": "electron .",
"build:linux": "electron-builder --linux --dir",
"dist:linux": "electron-builder --linux"
}
}
- Let's ensure that we can build the application for local testing. Run the first script in the Terminal window:
npm run build:linux
- In the project's root, you should see the dist/linux-unpacked folder, which contains several build artifacts:

- Now, let's see what you get when you're building packages for distribution. Run the second command, as shown in the following code:
npm run dist:linux
- This time, you are going to get multiple packages in the dist folder, as shown in the following screenshot:

The files that will be in your output folder are as follows:
- my-first-app 1.0.0.AppImage: The AppImage format is a universal software packaging format for all GNU/Linux distros.
- my-first-app_1.0.0_amd64.snap: This is a snap file, another popular format for sandboxed applications.
- linux-unpacked/my-first-app: This is the unpacked build for local testing and custom distributions.
- For now, double-click on my-first-app 1.0.0.AppImage to run the app. If you get the Would you like to integrate my-first-app with your system dialog, click No.
- This will be your final output:

Congratulations—you've got your first cross-platform Electron application package up and running on Ubuntu Linux!
推薦閱讀
- C#程序設計實訓指導書
- Java 開發從入門到精通(第2版)
- GeoServer Cookbook
- Building a Home Security System with Raspberry Pi
- Java應用開發與實踐
- Programming ArcGIS 10.1 with Python Cookbook
- Java編程技術與項目實戰(第2版)
- C#程序設計基礎:教程、實驗、習題
- Creating Stunning Dashboards with QlikView
- Node學習指南(第2版)
- 快樂編程:青少年思維訓練
- jQuery Mobile Web Development Essentials(Second Edition)
- C/C++代碼調試的藝術
- C語言程序設計實驗指導與習題精解
- Learning GraphQL and Relay