I am trying to turn my electron app to windows portable

13,741

Try putting "win": { "target": ["portable"] } and "portable": { "artifactName": "pvmplayer_portable.exe" } in "build", portable file will be created as pvmplayer_portable.exe:

{
    "name": "pvmplayer",
    "version": "1.0.0",
    "description": "",
    "main": "main.js",
    "scripts": {
        "postinstall": "install-app-deps",
        "start": "npm install && electron .",
        "pack": "build --dir",
        "dist": "build"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "ajv": "^6.5.1",
        "electron": "^2.0.2",
        "electron-builder": "^20.15.1"
    },
    "optionalDependencies": {},
    "dependencies": {},
    "build": {
        "productName": "PVM Player",
        "appId": "scripter.PVMplayer",
        "win": {
            "target": ["portable"]
        },
        "portable": {
            "artifactName": "pvmplayer_portable.exe"
        },
        "directories": {
            "output": "electron/output",
            "app": "electron/app",
            "buildResources": "electron/buildResources"
        }
    }
}
Share:
13,741
ΒΑΣΙΛΗΣ ΧΑΡΛΑΥΤΗΣ
Author by

ΒΑΣΙΛΗΣ ΧΑΡΛΑΥΤΗΣ

Updated on August 22, 2022

Comments

  • ΒΑΣΙΛΗΣ ΧΑΡΛΑΥΤΗΣ
    ΒΑΣΙΛΗΣ ΧΑΡΛΑΥΤΗΣ over 1 year

    I have searched a lot, but nothing really helped to build my app as portable. No mater what I do always the result is a nsis.

    It follows the package.json:

      {
      "name": "pvmplayer",
      "version": "1.0.0",
      "description": "",
      "main": "main.js",
      "scripts": {
        "postinstall": "install-app-deps",
        "start": "npm install && electron .",
        "pack": "build --dir",
        "dist": "build"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "ajv": "^6.5.1",
        "electron": "^2.0.2",
        "electron-builder": "^20.15.1"
      },
      "optionalDependencies": {},
      "dependencies": {},
      "electronBuilder": {
        "build": {
          "productName": "PVM Player",
          "appId": "scripter.PVMplayer",
          "win": {
            "target": ["portable"]
          },
          "directories": {
            "output": "electron/output",
            "app": "electron/app",
            "buildResources": "electron/buildResources"
          }
        }
      }
    }
    

    Is there any good guide to follow?

  • Leonardo Rick
    Leonardo Rick about 3 years
    Hi, what's the command and library you're using to build the package?
  • Hai Pham
    Hai Pham about 3 years
    @LeonardoRick as in the package.json I used electron-builder for building, with the command npm run dist