Electron-packager: "Invalid package error" when using asar

Created on 2 Aug 2018  路  7Comments  路  Source: electron/electron-packager

  • [ ] I have read the contribution documentation for this project.
  • [ ] I agree to follow the code of conduct that this project follows, as appropriate.
  • [ ] I have searched the issue tracker for an issue that matches the one I want to file, without success.
    Please describe your issue:
    1."electron": "^2.0.5"
    2."electron-packager": "^12.1.0"
    I want to package application include another application, it's a packaged application.But something error .(A JavaScript error occurred in the main process).
    first, I use "electron-packager . --platform=darwin --electron-version=2.0.5 --overwrite --ignore=.gitignore". It's success to build a wrap application.
    second, Wrap application use nodejs to create some files like package.json and main.js, then I use the electron-packager API "packager" to build new project and something error.Please help.
Unhandled rejection Error: Invalid package /private/var/folders/2w/13b_340j6qj0xtz5jgcyzj7w0000gn/T/electron-packager/darwin-x64-template/Electron.app/Contents/Resources/default_app.asar
    at invalidArchiveError (ELECTRON_ASAR.js:153:19)
    at Object.module.(anonymous function) [as open] (ELECTRON_ASAR.js:209:16)
    at WriteStream.open (fs.js:2158:6)
    at new WriteStream (fs.js:2144:10)
    at Object.fs.createWriteStream (fs.js:2106:10)

Most helpful comment

I found a solution :
Turn off the asar functionality and then run it.
process.noAsar = true;

All 7 comments

馃憢 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 馃悶 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using the electron-quick-start repository as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?

I have the same problem with electron-packager on Win 10:

Same resut with a new app create with the electron-quick-start as a base

Packaging app for platform win32 ia32 using electron v2.0.6
Unhandled rejection Error: Invalid package C:\Users\suppo\AppData\Local\Temp\electron-packager\win32-ia32-template\resources\default_app.asar at invalidArchiveError (ELECTRON_ASAR.js:153:19) at Object.module.(anonymous function) [as open] (ELECTRON_ASAR.js:209:16) at WriteStream.open (fs.js:2158:6) at new WriteStream (fs.js:2144:10) at Object.fs.createWriteStream (fs.js:2106:10) at writeStream (C:\Electron\open-grid\node_modules\extract-zip\index.js:175:36) at C:\Electron\open-grid\node_modules\extract-zip\index.js:172:18 at C:\Electron\open-grid\node_modules\yauzl\index.js:439:7 at C:\Electron\open-grid\node_modules\yauzl\index.js:473:5 at C:\Electron\open-grid\node_modules\fd-slicer\index.js:32:7 at FSReqWrap.wrapper [as oncomplete] (fs.js:658:17)

But If i extract manualy the package
C:\Users\suppo\AppData\Local\electron\Cache\electron-v2.0.0-win32-ia32.zip
into
C:\Users\suppo\AppData\Local\Temp\electron-packager

A new error is show :

`Unhandled rejection Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\suppo\AppData\Local\Temp\electron-packager\win32-ia32-template\resources'
electron-quick-start.zip

`

@LudiscapeXApi I cannot reproduce this on Linux with your zip file. The packaged app runs normally.

Why are you specifying prune: false?

I cannot reproduce this on Ubuntu 18 too. Only on Win 10.
prune false/true same result :
Packaging app for platform win32 ia32 using electron v2.0.6 Unhandled rejection Error: Invalid package C:\Users\suppo\AppData\Local\Temp\electron-packager\win32-ia32-template\resources\default_app.asar at invalidArchiveError (ELECTRON_ASAR.js:153:19) at Object.module.(anonymous function) [as open] (ELECTRON_ASAR.js:209:16)
and next :
Unhandled rejection Error: ENOTEMPTY: directory not empty, rmdir C:\Users\suppo\AppData\Local\Temp\electron-packager\win32-ia32-template\resources

I found a solution :
Turn off the asar functionality and then run it.
process.noAsar = true;

@LudiscapeXApi @malept thank you guys.I set process.noAsar = true.The packaged app runs normally.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kdawg1406 picture kdawg1406  路  4Comments

Liam-Ryan picture Liam-Ryan  路  4Comments

wgrhstf picture wgrhstf  路  4Comments

Orrison picture Orrison  路  3Comments

rafaelcastrocouto picture rafaelcastrocouto  路  3Comments