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
- Now from https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/188 — committed to baruchiro/israeli-bank-scrapers-desktop by baruchiro 4 years ago
- Changed "src/background.js" to "background.js". Intended to fix error during build. Resolves https://github.com/MediaWikiAGE/MAGE/issues/6 See also: https://github.com/nklayman/vue-cli-plugin-electr... — committed to BryghtShadow/MAGE by BryghtShadow 4 years ago
- Changed "src/background.js" to "background.js". (#7) Intended to fix error during build. Resolves https://github.com/MediaWikiAGE/MAGE/issues/6 See also: https://github.com/nklayman/vue-cli-plugi... — committed to MediaWikiAGE/MAGE by BryghtShadow 4 years ago
- Update main.yml Trying to fix build error. Ref. https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/188#issuecomment-998407931 — committed to mcicolella/vue-electron by mcicolella 2 years ago
- Update dependencies and add npm setup script - Introduce `fresh-npm-install.sh` to automate clean npm environment setup. - Revert workaround 924b326244a175428175e0df3a50685ee5ac2ec6, resolved by ... — committed to undergroundwires/privacy.sexy by undergroundwires a year ago
- Update dependencies and add npm setup script - Introduce `fresh-npm-install.sh` to automate clean npm environment setup. - Revert workaround 924b326244a175428175e0df3a50685ee5ac2ec6, resolved by ... — committed to undergroundwires/privacy.sexy by undergroundwires a year ago
- Update dependencies and add npm setup script - Introduce `fresh-npm-install.sh` to automate clean npm environment setup. - Revert workaround ff134da9a77b74ae48cc09762b735c956e38e833, resolved by ... — committed to LarrMarburger/privacy.sexy by LarrMarburger a year ago
- Now from https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/188 — committed to SuperStar511/Israeli-bank-react by SuperStar511 4 years ago
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
: fromto
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 yourpackage.json
tobackground.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:
@DatMoser remove the
files
option from yourpackage.json
underbuild
.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.
errordist/
vsdist_electron/
problems"main": "background.js",
vs"main": "src/background.js",
vue.config.js
problems remainProcessFile: 'src/background.js',
andfiles: ['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 workflowyml
file. Keep your package.json containing the default"main": "background.js"
, and you don’t need to do anything tovue.config.js
.Detail
In a Github Actions workflow
yml
file, specifying theuse_vue_cli: true
option to the samuelmeuli/action-electron-builder@v1 causes this good invocation e.g.:instead of the problematic, plain electron-builder invocation, which builds in the
dist/
directory instead ofdist_electron/
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.Remember:
use_vue_cli
option to be specified, which triggers the invocation of the above vue plugin, which then in turn triggers invoking electron builder in a special way, with extra configs or something. Without theuse_vue_cli
in your workflowyml
file, a plain electron builder invocation is made, which won’t handle vue stuff properly.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
bynpm install -g asar
, then extract the app.asar file with asar simply byasar 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 themain
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!
All args you pass to
electron:build
will be forwarded to electron-builder, so just set your script tovue-cli-service electron:build --linux
Thanks @nklayman
I did as you said. Still the same error:
The package.json:
The vue.config.js:
The unzipped
\dist\win-unpacked\resources\app.asar
looks like this:The unzipped
\dist_electron\win-unpacked\resources\app.asar
looks like this:Looks like the error says it is looking in
dist
directory rather then indist_electron
. Any idea?Should it be
\dist_electron\win-unpacked\resources\app.asar
instead?