Electron-builder: Electron App Doesn't Launch After Packaging

Created on 25 Apr 2019  路  3Comments  路  Source: electron-userland/electron-builder


  • Version:
    20.39.0

  • Target:
    Any Target / Windows / Portable

My application is running just fine, but after packaging the application using electron-builder, the app doesn't launch. The exe gets produced and I don't see any errors/warnings in the console.

Is there any logging I can enable on the app or any other steps I can do to try and figure out what's going on? Here is my full package.json below. I think the build property is the most important (?)

Basically, I'm just trying to package my app into a single exe so I can distribute it. Forgive the unused scripts in the package.json as it's all my attempts at trying to package an app. I will say, the script build-win32 works fine. But, it doesn't end up as a single exe so I can't use it.

I am running npm run dist

{
  "name": "MyApp",
  "version": "1.0.0",
  "description": "my test app",
  "main": "main.js",
  "build": {
    "asar": true,
    "appId": "my.app",
    "productName": "MyApp",
    "win": {
      "target": "portable"
    }
  },
  "scripts": {
    "start": "electron .",
    "build-win32": "electron-packager . --asar --platform=win32 --arch=x64 --overwrite --executableName BTSniffer",
    "build-mac": "electron-packager . --asar",
    "postinstall": "electron-builder install-app-deps",
    "rebuild": "electron-rebuild -w sqlite3 -p",
    "forge": "electron-forge package",
    "pack": "electron-builder --dir",
    "dist": "electron-builder"
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/preset-env": "^7.4.3",
    "asar": "^1.0.0",
    "babel-loader": "^8.0.5",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "css-loader": "^2.1.1",
    "electron": "^4.1.3",
    "electron-builder": "^20.39.0",
    "electron-debug": "^2.2.0",
    "electron-packager": "^13.1.1",
    "electron-rebuild": "^1.8.4",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "uglifyjs-webpack-plugin": "^2.1.2"
  },
  "dependencies": {
    "express": "^4.16.4",
    "glob": "^7.1.3",
    "knex": "^0.16.3",
    "request-promise": "^4.2.4",
    "sql.js": "^0.5.0"
  }
}


Most helpful comment

@Slapbox. Did that, it crashes before it's got a chance to open the dev tools. I did, however figure out what the issue was. It was a missing module issue. I didn't have the module referenced anywhere in my project so that's a little confusing. The module in question was request

I figured this out by finding an electron logging package on npm (electron-log). I then wrapped my entire main.js file in a try/catch and logged the exception with electron-log. After that, I could then open the logfile and review the exception.

All 3 comments

@mswilson4040 your best bet is to enable devtools and open them on start in production, or do you mean the app doesn't even run? I strongly recommend using electron-unhandled, which will probably help you get to the bottom of this very quickly.

@Slapbox. Did that, it crashes before it's got a chance to open the dev tools. I did, however figure out what the issue was. It was a missing module issue. I didn't have the module referenced anywhere in my project so that's a little confusing. The module in question was request

I figured this out by finding an electron logging package on npm (electron-log). I then wrapped my entire main.js file in a try/catch and logged the exception with electron-log. After that, I could then open the logfile and review the exception.

Glad you figured it out!

Electron-unhandled is like automatically wrapping everything in a try/catch. I'm not sure of _exactly_ how it works, but that's pretty much the effect it has. Strongly recommend it, as it's super easy to implement and will probably save you hours or days. Also helps prevent production crashes from unforeseen bugs.

If you're all set, remember to close your issue.

Was this page helpful?
0 / 5 - 0 ratings