Electron-boilerplate works, electron-builder doesn't


Hi, I have a possibly stupid issue but struggling for days now. When I create an app (using Mac) with electron-boilerplate with npm run release the app package DMG is created with a file size of 42.8 MB and the installation is OK plus the app works fine, with a file size of 119.1 MB (checked after installing).

After installing electron-builder plus all requirements to pack apps for Mac and Windows and setting parameters for both platforms I’m trying to create applications for them. When I run npm run dist or build -ow the application that gets created in dist/mac subdirectory has 117.6 MB while the DMG package has 37.3 MB. Clearly both are smaller.

Running app gives an error

Uncaught Exception:
/Users/mattsrinc/Documents/Projekti/Electron/simple-browser/dist/mac/Simple Browser.app/Contents/Resources/app.asar/background.js:7
import { app } from ‘electron’;

so it’s clearly something wrong with including electron but I cannot find it where. Additional help if somebody has a simple solution:

node -v

Start of background.js (i’ve changed that ES6 references but it’s still no go):

const electron = require('electron');
const app = electron.app;
//import { app } from 'electron';

Adding electron or electron-prebuilt to app’s package.json doesn’t help neither.

UPDATE: it turned out that import statements were simply rejected. Took some hard lessons here, electron-boilerplate and Electron itself. So had to turn all import to require statements, and for now even had to copy the CSS (it does not get compiled from LESS, not an issue either). For the later, path issues that set of path adding statements and even the electron-compile package hasn’t helped either, and I had to deliver something to a client for a proof of concept.

If you have a definite solution which Electron (and when) versions and looks like graceful-fs will work together with ES6, do comment please. For now all the modern stuff is just that, not useful at this moment.


Have a look at my boilerplate, especially the React.js branch here: https://github.com/appelgriebsch/electron-boilerplate/tree/reactjs. It uses some nice, clean and simple npm build scripts (in the package.json) to compile jsx and ES6 via babel. Feel free to contribute.


Thank you. Looks nice - will most likely use for next projects. The last (and the first :slight_smile: ) was a pain because of ES6 discrepancy.

But Electron is definitely one of the only 3 open source development tools I intend to use till the rest of my career: Meteor, Electron and Kivy (I use this order to say MEK on my Mac :relaxed: ).

split this topic #4

2 posts were split to a new topic: Why Electron in a mobile-first world?

Why Electron in a mobile-first world?