Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ravipudi/c12716015ea0607fa5ab90184bc82396 to your computer and use it in GitHub Desktop.
Save ravipudi/c12716015ea0607fa5ab90184bc82396 to your computer and use it in GitHub Desktop.
Electron - Creating a windows portable executable

How to create a portable windows application without an installer from an electron project:

  1. Clone the electron-quick-start repo:
git clone https://github.com/electron/electron-quick-start
  1. yarn
  2. Make your application - probably edit main.js to navigate to some URL
  3. yarn add electron-packager
  4. Edit package.json - update the 'name' and add a new script 'packager':
{
  "name": "my-app-name",
  ...
  "scripts": {
	"start": "electron .",
    "packager": "electron-packager ./ --platform=win32"
  }
}
  1. 'npm start' will bring up the application
  2. 'npm run packager' will package the app for windows. You will see a new directory 'my-app-name-win32-x64' in the top directory of the project, with a my-app-name.exe
@poa00
Copy link

poa00 commented Jun 14, 2024

FYI, I found this gist looking for an ALTERNATIVE to the steps above. Following this guide creates a portable executable in a sense, but that resulting executable still writes to %APPDATA% which IMO is not very portable. (EXAMPLE: running the .exe from a flash drive on different machines, you'll find that none of the config settings / files / customizations will not be retained).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment