Electron - Packaging an App


#1

Hello,

I have been working on an app using Electron. I’m now ready to package it. However, I’m running into a problem. While the app runs fine during development, my packaged version does not start. Instead, when I click the “MyApp.app” file in OS X Finder, I get a window that says:

"Welcome to Electron (v0.36.4)
To run your app with Electron, execute the following command under your Console (or Terminal)
...
"

I suspect I’m getting this error because of the way my code is structured. At this time, I have the following directories:

.
  /dist
  /packaged
  /src
  /tests

The “src” file is where I write my code. The “dist” directory contains the app after its been minified, etc. via gulp. The “packaged” directory contains the apps created by running electron-packager. The “tests” directory has my unit tests.

My package.json file looks something like this:

{
  "name": "MyApp",
  "description": "This is a test",
  "version": "1.0.0",
  "dependencies": {
    ...
  },
  "engines": {
    "node": "4.0.0"
  },
  "scripts": {
    "start": "electron src/index.html.js",
    "build": "electron-packager ./dist/. MyApp --platform=all --arch=all --version=0.36.4 --out=packaged"
  },
  },
  "devDependencies": {
    "electron-packager": "^5.2.0",
    "electron-prebuilt": "^0.36.4"
  }
}

It seems so odd. npm run start works fine. However npm run build does not. I checked and there are in fact contents in the “./dist” directory. Those files are simply: “index.html.js” and “index.html”. I can’t seem to figure under what circumstance I would even get the screen mentioned above. Any help is appreciated!


#2

I would try making 3 separate commands, maybe like build_mac or something. See if the problem persists. I also think your out might need to be ‘./packaged’ but I’m running windows and its really particular about those things.