Electron Forge Maker Deb is a TypeScript library that creates Debian (.deb) packages for Electron applications. It provides a maker plugin for the Electron Forge build system, enabling developers to package their Electron apps for Debian-based Linux distributions like Ubuntu. The package integrates with the electron-installer-debian tool and handles architecture mapping, external dependencies, and comprehensive Debian package configuration.
yarn add @electron-forge/maker-deb or npm install @electron-forge/maker-debimport MakerDeb, { debianArch, MakerDebConfig } from "@electron-forge/maker-deb";Named imports:
import { MakerDeb, debianArch, MakerDebConfig } from "@electron-forge/maker-deb";For CommonJS:
const MakerDeb = require("@electron-forge/maker-deb");
const { MakerDeb: NamedMakerDeb, debianArch } = require("@electron-forge/maker-deb");import MakerDeb from "@electron-forge/maker-deb";
// Configure the maker in your forge.config.js
const config = {
makers: [
{
name: '@electron-forge/maker-deb',
config: {
options: {
maintainer: 'The Forgers',
homepage: 'https://example.com',
icon: 'path/to/icon.svg',
section: 'utils',
priority: 'optional'
}
}
}
]
};
// Or use programmatically
const maker = new MakerDeb({
options: {
maintainer: 'Your Name',
homepage: 'https://yourapp.com',
icon: './assets/icon.png'
}
});The Maker Deb package is built around several key components:
Core functionality for creating .deb packages from Electron applications, with full Debian package specification compliance.
class MakerDeb extends MakerBase<MakerDebConfig> {
/** Maker identifier */
name: string;
/** Supported platforms for this maker */
defaultPlatforms: ForgePlatform[];
/** Required external system binaries */
requiredExternalBinaries: string[];
/** Check if maker is supported on current platform */
isSupportedOnCurrentPlatform(): boolean;
/** Create Debian package from Electron application */
make(options: MakerOptions): Promise<string[]>;
}The MakerDeb class inherits additional utility methods from MakerBase:
class MakerDeb extends MakerBase<MakerDebConfig> {
/** Helper method to ensure directory exists and is empty */
ensureDirectory(dir: string): Promise<void>;
/** Helper method to ensure file path exists and file does not exist */
ensureFile(file: string): Promise<void>;
/** Check if external binaries exist on the system */
externalBinariesExist(): boolean;
/** Throw error if external binaries don't exist */
ensureExternalBinariesExist(): void;
/** Check if a Node.js module is installed */
isInstalled(module: string): boolean;
/** Normalize semver version to 4-part Windows format */
normalizeWindowsVersion(version: string): string;
}Utility function for converting Node.js architecture names to Debian package architecture conventions.
/**
* Convert Node.js architecture to Debian package architecture
* @param nodeArch - Node.js architecture identifier
* @returns Debian architecture string
*/
function debianArch(nodeArch: ForgeArch): string;Usage Examples:
import { debianArch } from "@electron-forge/maker-deb";
// Architecture conversions
console.log(debianArch('x64')); // 'amd64'
console.log(debianArch('ia32')); // 'i386'
console.log(debianArch('armv7l')); // 'armhf'
console.log(debianArch('arm')); // 'armel'
console.log(debianArch('arm64')); // 'arm64' (passed through)Comprehensive configuration options for customizing Debian package metadata, dependencies, and behavior.
interface MakerDebConfig {
/** Configuration options for Debian package creation */
options?: MakerDebConfigOptions;
}
interface MakerDebConfigOptions {
/** Package name for Debian control specification */
name?: string;
/** Application name for desktop specification */
productName?: string;
/** Generic application name for desktop specification */
genericName?: string;
/** Short description for control specification */
description?: string;
/** Long description for control specification */
productDescription?: string;
/** Package version for control specification */
version?: string;
/** Package revision for control specification */
revision?: string;
/** Application category for Debian package classification */
section?: 'admin' | 'cli-mono' | 'comm' | 'database' | 'debian-installer' | 'debug' | 'devel' | 'doc' | 'editors' | 'education' | 'electronics' | 'embedded' | 'fonts' | 'games' | 'gnome' | 'gnu-r' | 'gnustep' | 'graphics' | 'hamradio' | 'haskell' | 'httpd' | 'interpreters' | 'introspection' | 'java' | 'javascript' | 'kde' | 'kernel' | 'libdevel' | 'libs' | 'lisp' | 'localization' | 'mail' | 'math' | 'metapackages' | 'misc' | 'net' | 'news' | 'ocaml' | 'oldlibs' | 'otherosfs' | 'perl' | 'php' | 'python' | 'ruby' | 'rust' | 'science' | 'shells' | 'sound' | 'tasks' | 'tex' | 'text' | 'utils' | 'vcs' | 'video' | 'virtual' | 'web' | 'x11' | 'xfce' | 'zope';
/** Package priority level */
priority?: 'required' | 'important' | 'standard' | 'optional';
/** Estimated disk space requirement in kilobytes */
size?: number;
/** Package dependencies */
depends?: string[];
/** Recommended packages */
recommends?: string[];
/** Suggested packages */
suggests?: string[];
/** Enhanced packages */
enhances?: string[];
/** Pre-dependencies */
preDepends?: string[];
/** Package maintainer contact information */
maintainer?: string;
/** Homepage URL for the application */
homepage?: string;
/** Relative path to executable binary */
bin?: string;
/** Path to application icon file */
icon?: string;
/** Desktop application categories */
categories?: ('AudioVideo' | 'Audio' | 'Video' | 'Development' | 'Education' | 'Game' | 'Graphics' | 'Network' | 'Office' | 'Science' | 'Settings' | 'System' | 'Utility')[];
/** Supported MIME types */
mimeType?: string[];
/** Lintian override rules */
lintianOverrides?: string[];
/** Package maintainer scripts */
scripts?: {
/** Pre-installation script path */
preinst?: string;
/** Post-installation script path */
postinst?: string;
/** Pre-removal script path */
prerm?: string;
/** Post-removal script path */
postrm?: string;
};
/** Custom desktop entry template path */
desktopTemplate?: string;
}Configuration Examples:
// Basic configuration
const basicConfig: MakerDebConfig = {
options: {
maintainer: 'Your Name <you@example.com>',
homepage: 'https://yourapp.com',
description: 'Your awesome Electron application',
section: 'utils',
priority: 'optional'
}
};
// Advanced configuration with dependencies
const advancedConfig: MakerDebConfig = {
options: {
maintainer: 'Development Team <dev@company.com>',
homepage: 'https://company.com/products/app',
description: 'Professional data analysis tool',
productDescription: 'A comprehensive data analysis application built with Electron, featuring advanced visualization and reporting capabilities.',
section: 'science',
priority: 'optional',
categories: ['Office', 'Science'],
depends: ['libnss3', 'libatk-bridge2.0-0'],
recommends: ['ca-certificates'],
icon: './assets/app-icon.png',
scripts: {
postinst: './debian/postinst',
prerm: './debian/prerm'
}
}
};/** Forge architecture types from @electron-forge/shared-types */
type ForgeArch = 'ia32' | 'x64' | 'armv7l' | 'arm64' | 'mips64el' | 'universal' | 'arm';
/** Forge platform types from @electron-forge/shared-types */
type ForgePlatform = 'darwin' | 'mas' | 'win32' | 'linux';
/** Maker options interface from @electron-forge/maker-base */
interface MakerOptions {
/** Directory containing the packaged Electron application */
dir: string;
/** Directory for output artifacts */
makeDir: string;
/** Human-friendly project name */
appName: string;
/** Target platform */
targetPlatform: ForgePlatform;
/** Target architecture */
targetArch: ForgeArch;
/** Resolved forge configuration */
forgeConfig: ResolvedForgeConfig;
/** Application package.json */
packageJSON: any;
}
/** Resolved forge configuration from @electron-forge/shared-types */
interface ResolvedForgeConfig {
/** Build identifier for uniquely identifying artifacts */
buildIdentifier?: string | (() => string);
/** Output directory (default: './out') */
outDir?: string;
/** Forge plugins configuration */
plugins: ForgeConfigPlugin[];
}The Maker Deb package requires specific external dependencies to function:
Installation on Ubuntu/Debian:
sudo apt-get install dpkg fakerootInstallation on macOS (via Homebrew):
brew install dpkg fakerootThe maker will throw errors in the following scenarios:
Example error handling:
try {
const maker = new MakerDeb(config);
const packagePaths = await maker.make(options);
console.log('Created packages:', packagePaths);
} catch (error) {
if (error.message.includes('external binaries')) {
console.error('Install required system dependencies: dpkg, fakeroot');
} else if (error.message.includes('electron-installer-debian')) {
console.error('Install electron-installer-debian package');
} else {
console.error('Package creation failed:', error.message);
}
}