vue-cli-plugin-electron-builder: Application entry file "electron/bundled/background.js" in the "....app.asar" does not exist

Describe the bug Looks like there is some misconfiguration happening with electron-builder

To Reproduce Run the following:

git clone git://github.com/osapps/dotsync
cd dotsync
yarn
cd packages/app
npm run electron:build

Expected behavior Building should work

Screenshots


 INFO  Building app with electron-builder:
  • electron-builder version=20.38.5
  • writing effective config file=electron/builder-effective-config.yaml
  • no native production dependencies
  • packaging       platform=darwin arch=x64 electron=3.1.3 appOutDir=electron/mac
  • default Electron icon is used reason=application icon is not set
 ERROR  Error: Application entry file "electron/bundled/background.js" in the "/Users/pksunkara/Coding/osapps/dotsync/packages/app/electron/mac/Dotsync.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
Error: Application entry file "electron/bundled/background.js" in the "/Users/pksunkara/Coding/osapps/dotsync/packages/app/electron/mac/Dotsync.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
    at error (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/out/asar/asarFileChecker.js:44:14)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/asar/asarFileChecker.ts:30:4
From previous event:
    at _checkFileInArchive (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/asar/asarFileChecker.ts:36:17)
    at checkFileInArchive (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/out/asar/asarFileChecker.js:40:30)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:409:13
    at Generator.next (<anonymous>)
From previous event:
    at MacPackager.checkFileInPackage (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:406:110)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:460:16
    at Generator.next (<anonymous>)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/graceful-fs/polyfills.js:285:20
    at FSReqWrap.oncomplete (fs.js:159:5)
From previous event:
    at MacPackager.sanityCheckPackage (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:446:92)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:249:16
    at Generator.next (<anonymous>)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
    at MacPackager.doPack (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/platformPackager.ts:167:165)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/macPackager.ts:88:63
    at Generator.next (<anonymous>)
From previous event:
    at MacPackager.pack (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/macPackager.ts:80:95)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:430:24
    at Generator.next (<anonymous>)
    at xfs.stat (/Users/pksunkara/Coding/osapps/dotsync/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/graceful-fs/polyfills.js:285:20
    at FSReqWrap.oncomplete (fs.js:159:5)
From previous event:
    at Packager.doBuild (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:396:24)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:366:57
    at Generator.next (<anonymous>)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/graceful-fs/graceful-fs.js:111:16
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.oncomplete (fs.js:145:20)
From previous event:
    at Packager._build (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:335:133)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:331:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
    at Packager.build (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/packager.ts:288:14)
    at build (/Users/pksunkara/Coding/osapps/dotsync/node_modules/app-builder-lib/src/index.ts:59:28)
    at Object.build (/Users/pksunkara/Coding/osapps/dotsync/node_modules/electron-builder/src/builder.ts:227:10)
    at buildApp (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/index.js:176:14)
    at bundle.run (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/index.js:158:15)
    at finalCallback (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:220:39)
    at hooks.done.callAsync.err (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:269:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/pksunkara/Coding/osapps/dotsync/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/pksunkara/Coding/osapps/dotsync/node_modules/tapable/lib/Hook.js:154:20)
    at emitRecords.err (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:267:22)
    at Compiler.emitRecords (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:449:39)
    at emitAssets.err (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:261:10)
    at hooks.afterEmit.callAsync.err (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:435:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/pksunkara/Coding/osapps/dotsync/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/pksunkara/Coding/osapps/dotsync/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/Users/pksunkara/Coding/osapps/dotsync/node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/Compiler.js:432:27)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/neo-async/async.js:2813:7
    at done (/Users/pksunkara/Coding/osapps/dotsync/node_modules/neo-async/async.js:3521:9)
    at /Users/pksunkara/Coding/osapps/dotsync/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.oncomplete (fs.js:145:20)

Environment (please complete the following information):

  • OS and version: MacOS 10.13.1
  • node version: 10.6.0
  • npm version: 6.7.0
  • yarn version (if used): 1.12.3
  • vue-cli-plugin-electron-builder version : 1.0.0-rc.11
  • electron version: 3.1.3
  • other vue plugins used:
  • custom config for vcp-electron-builder:
  • (if possible) link to your repo: https://github.com/osapps/dotsync

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 34 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Actually valid value for that field is “./src/background.js”, thats why for example “electron .” command doesnt work (“Unable to find Electron app”)

The other part of the problem is that LTS version of Node doesnt work with ES6 without transpiling, but I beleive it will in couple of months, after that we will be able to quickly run app (~1s instead of ~20s with electron:serve), but the command will be long and a bit ugly “electron src/backgound.js” because of incorrect main in package.js

BTW, the names of main files are confusing because most Electron examples using main.js (its background.js here) and renderer.js (its main.js here)

Error fixed after changing the package.json: from

"main": "background.js"

to

"main": "dist_electron\bundled\background.js"

For @Flavsditz and anyone else finding this; the background.ts file is compiled to dist_electron/bundles/index.js so just change your “main” from “background.js” to “index.js” in your package.json.

Change the main field of your package.json to background.js.

I got the same problem:

Error: Application entry file "background.js" in the "/Users/xxx/Documents/npm/xxx-electron/vuecli/xxx/build/linux-unpacked/resources/app.asar" does not exist. Seems like a wrong configuration.

and my package.json:

"main": "background.js",

EDIT:

Sorry, I had a missconfiguration from the migrated repo in the build configs. Uncommenting ‘files’ fixed the issue:

pluginOptions: {
    electronBuilder: {
      builderOptions: {
        // files: ['dist_electron/**/*'], // This caused the build error

@DatMoser remove the files option from your package.json under build.

You may be getting all the errors mentioned in this issue when building your Vue based Electron app using GitHub Actions using the famous https://github.com/samuelmeuli/action-electron-builder GitHub Actions plugin. Thus your googling may lead you here. The errors are:

  • ...resources/app.asar" does not exist. Seems like a wrong configuration. error
  • dist/ vs dist_electron/ problems
  • package.json problems re "main": "background.js", vs "main": "src/background.js",
  • vue.config.js problems re mainProcessFile: 'src/background.js', and files: ['dist_electron/**/*'], etc.

As https://github.com/samuelmeuli/action-electron-builder/issues/66 says, you simply need to add use_vue_cli: true to your Github Actions workflow yml file. Keep your package.json containing the default "main": "background.js", and you don’t need to do anything to vue.config.js.

- name: Build/release Electron app
  uses: samuelmeuli/action-electron-builder@v1
  with:
    github_token: ${{ secrets.github_token }}
    use_vue_cli: true       # <-------- you need this
    release: ${{ startsWith(github.ref, 'refs/tags/v') }}

Detail

In a Github Actions workflow yml file, specifying the use_vue_cli: true option to the samuelmeuli/action-electron-builder@v1 causes this good invocation e.g.:

$ /Users/runner/work/vue-electron-builder1/vue-electron-builder1/node_modules/.bin/vue-cli-service electron:build --mac

instead of the problematic, plain electron-builder invocation, which builds in the dist/ directory instead of dist_electron/

$ /Users/runner/work/vue-electron-builder1/vue-electron-builder1/node_modules/.bin/electron-builder --mac

Look in your Github Action build logs to see which command is being invoked.

We want Vue with Electron via the Vue plugin vue-cli-plugin-electron-builder, not just plain Electron without Vue. The samuelmeuli/action-electron-builder@v1 plugin is all about building all sorts of Electron apps on Github, not specifically Vue based Electron apps. Though that Github action plugin is nice enough to give us this special Vue option.

use_vue_cli: true

Remember:

Hope this info helps someone, as it took me a while to figure out.

The file app.asar that mentioned in the error is basically a zipped file that stores the code of your electron application. (I am new to electron, if it’s not correct, don’t quote me on this, and please tell me how exactly it works.)

The ultimate way for me to solve this issue is to install a package called asar by npm install -g asar, then extract the app.asar file with asar simply by asar extract app.asar ./. Then you will see the app.asar file is extracted and it’s basically your whole project but zipped. I see that the main file is really depending on your configuration, that’s why all these solutions above might not be able to solve this problem in your case.

In my case, I used webpack to pack the files, and the packed main file located in dist/electron/main.js

If all the solutions above did not solve your issues, please try this way. Hope this could help!

image image

All args you pass to electron:build will be forwarded to electron-builder, so just set your script to vue-cli-service electron:build --linux

Thanks @nklayman

I did as you said. Still the same error:

Unpacking electron zip  zipPath=undefined
Application entry file "background.js" in the "C:\Code\MyProject\src\MyProject.App.Cmu\dist\win-unpacked\resources\app.asar" 
does not exist. Seems like a wrong configuration.  stackTrace=
Error: Application entry file "background.js" in the "C:\Code\MyProject\src\MyProject.App.Cmu\dist\win-unpacked\resources\app.asar"
 does not exist. Seems like a wrong configuration.
at error (C:\Code\MyProject\src\MyProject.App.Cmu\node_modules\app-builder-lib\src\asar\asarFileChecker.ts:7:12)

The package.json:

"devDependencies": {
    "electron": "^11.3.0",
    "electron-builder": "^22.10.5",
    "electron-devtools-installer": "^3.1.1",
    "vue-cli-plugin-electron-builder": "^2.0.0-rc.6",
    ....
}
"main": "background.js",

The vue.config.js:

module.exports = {
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      builderOptions: {
        appId: "com.myproject.cmu",
        productName: "My Project CMU",
        copyright: "Copyright © year ${author}",
        win: {
          target: "nsis",
          icon: "public/img/icons/logo_256x256.ico"
        },
        rpm: {
          category: "Other"
        }
      }
    }
  }
}

The unzipped \dist\win-unpacked\resources\app.asar looks like this: image

The unzipped \dist_electron\win-unpacked\resources\app.asar looks like this: image

Looks like the error says it is looking in dist directory rather then in dist_electron. Any idea?

Should it be \dist_electron\win-unpacked\resources\app.asar instead?