Electron App Doesn't Launch After Packaging

See original GitHub issue
  • 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"
  }
}


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

3reactions
marc-wilsoncommented, May 2, 2019

@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.

1reaction
Slapboxcommented, Jul 8, 2022

You can (and must) add the electron-unhandled code in the main process also for it to work.

Are you using electron-log as your logger? If so, you can configure the log function electron-unhandled will use when it encounters an unhandled error.

In our main process, we run this before almost any other code:

  const unhandled = require('electron-unhandled');
  unhandled({
    logger: log.error,
  });

With log.error being the function provided by electron-log. Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron App is not running after being packaged
1 Answer 1 · 1. Before packaging. Electron is executed from node_modules where it is in your app directory. · I read your...
Read more >
electron-packager - npm
Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI. Latest version: 17.1.1, last published: 2 ...
Read more >
Building your First App | Electron
This guide will step you through the process of creating a barebones Hello World app in Electron, similar to electron/electron-quick-start.
Read more >
A Comprehensive Guide to Building and Packaging an ...
Electron-forge only packages for your current platform, so it doesn't really work for packaging cross platform apps unless you own each of the ......
Read more >
Electron Builder: Packaging Electron (Nodejs) Application ...
So this piece elucidates how an Electron app can be packaged for Windows ... whether to run the application right after installation or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found