Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application entry file does not exist in Electron Builder

I have a minimal electron app and I am trying to build it (it runs fine). My package.json is

  "main": "main.js",
  "scripts": {
    "start": "electron -r babel-register .",
    "package": "build --dir",
    "postinstall": "electron-builder install-app-deps"
  },
  // dependencies
  "build": {
    "appId": "com.karmadust.mancuspianconvert",
    "files": [
      "node_modules/**/*"
    ],
    "directories": {
      "buildResources": "assets"
    }
  }

When I run npm run package I get:

Application entry file "main.js" in the "[path-to-project]/dist/mac/myapp.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
like image 358
Mike M Avatar asked Feb 20 '18 17:02

Mike M


1 Answers

You need to first build the main electron, you can use electron-webpack for that:

package.json

"scripts": {
    "compile": "electron-webpack",
    "build": "yarn compile && electron-builder" // Compile main first
  },
"electronWebpack": {
    "commonSourceDirectory": "common",
    "main": {
      "sourceDirectory": "main" // The main folder
    },
    "renderer": {
      "sourceDirectory": null // Ignore any renderer build
    },
 }

It will create a main folder inside your dist with the main.js build-in.

You can take a look at Electron webpack documentation for more information.

like image 140
Marcelo Formentão Avatar answered Oct 15 '22 10:10

Marcelo Formentão