Asked 7 years ago
25 Nov 2017
Views 1819
jaggy

jaggy posted

how to make .exe from electron js code ?

how to make .exe from electron js code ?
sachin

sachin
answered Feb 25 '23 00:00

Electron.js is a popular framework for building cross-platform desktop applications using web technologies such as HTML, CSS, and JavaScript. Here are the steps to package your Electron.js code into a Windows executable (.exe) file:

Install the electron-packager package globally using npm:


npm install electron-packager -g

Open your Electron.js project directory in a command prompt or terminal window.

Run the electron-packager command with the appropriate options. Here's an example command to package an Electron.js project as a Windows executable:



electron-packager . my-electron-app --platform=win32 --arch=x64 --electron-version=<your electron version> --icon=app.ico

In this command, replace <your electron version> with the version of Electron.js you are using, and app.ico with the name of your app icon file.

The electron-packager command will create a new directory called my-electron-app-win32-x64 (or similar) in your project directory. This directory contains the packaged Electron.js application as a Windows executable (.exe) file.

Test the packaged application by running the .exe file on a Windows machine.

Note that this is just one example of how to package an Electron.js application as a Windows executable. There are other tools and methods available, such as electron-builder and Electron Forge, which offer more features and flexibility.
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00


# for use in npm scripts
npm install electron-packager --save-dev

# for use from cli
npm install electron-packager -g



electron-packager . example --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="Electron Tutorial App"
Rasi

Rasi
answered Nov 30 '-1 00:00


npm install electron-builder --save-dev



npm install electron-builder-squirrel-windows


chnage package.json (i used for window build only )


"scripts": {
    "postinstall": "install-app-deps",
    "start": "npm install && electron ./app",
    "pack": "build --dir",
    "dist": "build"
  },
  "build": {
    "appId": "yourappid",
    "win": {
      "target": "squirrel",
     }
  }



npm run dist
Post Answer