Builds Snap packages for Electron applications that have already been bundled with electron-packager. Current stable version is 5.2.0, released in 2021 with dependency reductions, TypeScript definitions, and a default confinement change from classic to strict. Requires Node 10+ and snapcraft. Key differentiators: integrates with Electron Forge, autodetects base snap option, and handles Electron sandbox features for Snap confinement.
npm install electron-installer-snapVerified import paths — ran on the pinned version, not inferred.
Shows how to use the JavaScript API with async/await to create a Snap package from an electron-packager output directory.
Explicitly set confinement to 'classic' if your app requires classic confinement, or adjust your app to work under strict confinement.
Use async/await or util.callbackify() to convert the promise-based API.
Ensure your Node.js version is >= 10.
Install snapcraft (e.g., 'sudo snap install snapcraft --classic') and ensure it's available, or specify its path via the 'snapcraft' option.
Verify that 'src' contains the full electron-packager output (with app binary, resources, etc.).
Set the 'base' option (e.g., 'core18', 'core20') explicitly or rely on autodetection; check snapcraft requirements.
Install snapcraft: sudo snap install snapcraft --classic
Ensure the 'name' option uses only [a-z0-9-]
Use import or dynamic import: const installer = (await import('electron-installer-snap')).defaultRun electron-packager first and provide the correct output directory