Electron Builder中不存在应用程序条目文件

时间:2018-02-20 17:37:25

标签: node.js electron electron-builder

我有一个最小的电子应用程序,我正在尝试构建它(运行正常)。我的package.json是

  "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"
    }
  }

当我运行npm run package时,我得到:

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.

2 个答案:

答案 0 :(得分:3)

您需要首先构建主电子,您可以使用electron-webpack

的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
    },
 }

它将使用main内置版在您的dist中创建一个main.js文件夹。

您可以查看Electron webpack文档以获取更多信息。

答案 1 :(得分:0)

@Marcelo 关于需要编译和构建源文件是正确的。但我要提醒你不要electron-webpack,因为it's become unreliable

结帐 these boilerplates 以了解其他一些选项,其中许多选项在幕后使用 electron-builder