Luke Luke - 1 year ago 234
Node.js Question

Electron Packager On Windows Does Nothing

I have written a small app with Electron in Windows and have some functionality which inspects the registry for information about some software that is installed, and I need to run the app on another machine to test. So, I am trying to package my app.

Firstly, it is important to note that when I run

>electron .
in the root of my project, it runs without any issues.

I have tried manually packaging the app, by placing my app under the
folder and running Electron.exe. It doesn't work. The Electron app starts up in task manager before exiting just as quickly. Without any errors or warnings. No dialogs or anything.

I have installed the electron-packager module, and tried to use that to package the app. However, it does nothing. There is no console output, it just sits there for a while before exiting. And when it exits, there is no packaged app. Nothing has changed. I tried electron-builder and got the same result.

I am new to node in general, so I suspect I am simply doing something wrong. This is my package.json (which I still don't fully understand the purpose of):

"name": "welcome",
"version": "0.1.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron .",
"compile": "node .\\node_modules\\webpack\\bin\\webpack.js",
"prep": "robocopy . releases\\app /XD node_modules releases blah /S /MIR /XF *.jsx \"webpack.config.js\" && robocopy node_modules\\winreg releases\\app && robocopy node_modules\\path releases\\app",
"package": "asar pack .\\releases\\app .\\releases\\app.asar",
"build": "electron-packager releases\\app WelcomeApp --ignore=node_modules --platform=win32 --arch=x64 --output=releases"
"author": "",
"license": "ISC",
"babel": {},
"dependencies": {
"electron": "^1.3.4",
"path": "^0.12.7",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"winreg": "^1.2.1"
"devDependencies": {
"babel-core": "^6.13.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.13.1",
"babel-preset-react": "^6.11.1",
"electron-builder": "^5.34.1",
"electron-packager": "^7.7.0",
"webpack": "^1.13.1"

My directory structure is as follows

| |____src
| | |____dist
| | | |____bundle.js
| | |____react
| | | |____components
| | | | |____installation.jsx
| | | | |____...
| | | | |____software.jsx
| | | |____index.jsx
| | |____util
| | |____data.js
| |____app.html
| |____...

There is no problem with what I am doing from what I can see. And like I said, when running with electron cli (
electron .
) it works perfectly fine. So, I am at a loss. I can only presume there is probably something wrong with the package.json. Is there an issue? Why am I not seeing any console output when running the packager?

Answer Source

i'll leave you my script of how i package my application with the API of electron-packager, maybe you can build your.exe with this.

'use strict';
var packager = require('electron-packager');
var options = {
    'arch': 'ia32',
    'platform': 'win32',
    'dir': './',
    'app-copyright': 'Paulo Galdo',
    'app-version': '2.1.6',
    'asar': true,
    'icon': './app.ico',
    'name': 'TierraDesktop',
    'out': './releases',
    'overwrite': true,
    'prune': true,
    'version': '1.3.4',
    'version-string': {
        'CompanyName': 'Paulo Galdo',
        'FileDescription': 'Tierra de colores', /*This is what display windows on task manager, shortcut and process*/
        'OriginalFilename': 'TierraDesktop',
        'ProductName': 'Tierra de colores',
        'InternalName': 'TierraDesktop'
packager(options, function done_callback(err, appPaths) {
    console.log("Error: ", err);
    console.log("appPaths: ", appPaths);

Here you can see all the options you can use on this script: link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download