{"id":18291,"library":"electron-installer-snap","title":"Electron Snap Installer","description":"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.","status":"active","version":"5.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/electron-userland/electron-installer-snap","tags":["javascript","electron","installer","snap","snapcraft","linux","typescript"],"install":[{"cmd":"npm install electron-installer-snap","lang":"bash","label":"npm"},{"cmd":"yarn add electron-installer-snap","lang":"bash","label":"yarn"},{"cmd":"pnpm add electron-installer-snap","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to build the .snap package","package":"snapcraft","optional":false}],"imports":[{"note":"ESM-only since v4; use dynamic import or transpile for CJS","wrong":"const installer = require('electron-installer-snap')","symbol":"default","correct":"import installer from 'electron-installer-snap'"},{"note":"Named export for advanced use; available since v5 with TypeScript types","wrong":"","symbol":"createApp","correct":"import { createApp } from 'electron-installer-snap'"},{"note":"TypeScript-only interface, not a runtime export","wrong":"import { SnapcraftConfig } from 'electron-installer-snap'","symbol":"SnapcraftConfig","correct":"import type { SnapcraftConfig } from 'electron-installer-snap'"}],"quickstart":{"code":"import installer from 'electron-installer-snap';\n\nconst options = {\n  src: 'out/myappname-linux-x64',\n  dest: 'dist/',\n  arch: 'amd64',\n  name: 'myapp',\n  productName: 'My App',\n  version: '1.0.0',\n  description: 'My Electron App',\n  summary: 'A snap of My App',\n  license: 'Apache-2.0',\n  base: 'core18',\n  confinement: 'strict',\n  grade: 'stable',\n  assumes: ['snapd2.43'],\n  plugs: ['home', 'x11', 'wayland', 'unity7', 'pulseaudio', 'opengl'],\n  slots: [],\n  stages: ['-usr/share/man'],\n  after: [],\n  electronVersion: '11.0.0',\n  snapcraft: '/snap/bin/snapcraft',\n  template: '/path/to/template.snapcraft.yaml',\n};\n\nasync function buildSnap() {\n  try {\n    await installer(options);\n    console.log('Snap package created successfully');\n  } catch (err) {\n    console.error('Snap creation failed:', err);\n  }\n}\n\nbuildSnap();","lang":"typescript","description":"Shows how to use the JavaScript API with async/await to create a Snap package from an electron-packager output directory."},"warnings":[{"fix":"Explicitly set confinement to 'classic' if your app requires classic confinement, or adjust your app to work under strict confinement.","message":"The default confinement has changed from 'classic' to 'strict' in v5.2.0.","severity":"breaking","affected_versions":">=5.2.0"},{"fix":"Use async/await or util.callbackify() to convert the promise-based API.","message":"Callback-style support was removed in v4.0.0.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure your Node.js version is >= 10.","message":"Node.js 10 is the minimum required version; Node.js 8 support was dropped in v5.0.0.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Install snapcraft (e.g., 'sudo snap install snapcraft --classic') and ensure it's available, or specify its path via the 'snapcraft' option.","message":"The 'snapcraft' command-line tool must be installed separately and may not be in PATH.","severity":"deprecated","affected_versions":"all"},{"fix":"Verify that 'src' contains the full electron-packager output (with app binary, resources, etc.).","message":"EINVAL errors often occur when the 'src' path points to an invalid or incomplete Electron app directory.","severity":"gotcha","affected_versions":"all"},{"fix":"Set the 'base' option (e.g., 'core18', 'core20') explicitly or rely on autodetection; check snapcraft requirements.","message":"Snap builds may fail if the 'base' option is not set correctly for your Electron version.","severity":"gotcha","affected_versions":">=4.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install snapcraft: sudo snap install snapcraft --classic","cause":"snapcraft is not installed or not in PATH","error":"Error: spawn snapcraft ENOENT"},{"fix":"Ensure the 'name' option uses only [a-z0-9-]","cause":"Snap names must be lowercase alphanumeric with hyphens","error":"Error: Invalid snap name: my.app (invalid characters)"},{"fix":"Use import or dynamic import: const installer = (await import('electron-installer-snap')).default","cause":"Using CommonJS require on an ESM-only module","error":"TypeError: installer is not a function"},{"fix":"Run electron-packager first and provide the correct output directory","cause":"Specified src path is incorrect or missing","error":"Error: The 'src' directory does not exist: /path/to/nonexistent"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}