0

Here's a weird problem I'm suffering for days.

I need to create an asar packed file, done with electron "asar" command, like this:

c:/asar pack app app.asar

That packs my "app" folder into a packed file "app.asar". Thats running OK.

The goal

I need to include this instruction inside my package.json script file in order to generate a build process, chainning other actions.

The problem:

Well, when I run this command, by package.json script like this c:/npm run create-asar or either with a gulp-asar process, it creates the app.asar file, but seems to be corrupted.

It can't be unpacked, process throws an error and can't be accessed by the electron app

enter image description here

I can't figure out why.

I've tried to run the exact same command from console, that in package.json, exactly the same, and both with the results above.

what's the difference?

versions info

  • npm: v3.10.6
  • node: v4.5.0
  • asar: v0.13.0
  • electron: v1.4.3
6
  • Perhaps you are encountering issue no. 74 regarding multibyte characters found in earlier versions. Try updating asar to a newer version. The issue was fixed in version 0.12.3. Alternatively, If updating is not feasible, then check for any multibyte characters in filenames/content and change them before the initial packing.
    – RobC
    Commented Feb 16, 2017 at 9:13
  • I'll try to update some packages, i'm using v0.13 on asar, but I'll give it a look. Commented Feb 16, 2017 at 9:41
  • still don't work. I'm going to update question with packages versions. Commented Feb 16, 2017 at 9:46
  • 1
    Then it's not a multibyte character issue if you're running v0.13. Try installing asar as a project dependency. I.e. cd to to project directory, run npm i -D asar to add it to devDependencies in package.json. Then update your npm-script to "create-asar": "node_modules/.bin/asar pack app app.asar". (Note asar is being run via the node_modules .bin folder). Then run $ npm run create-asar and see if it unpacks successfully.
    – RobC
    Commented Feb 16, 2017 at 9:58
  • @RobC with your instructions works! So it should be something related to another package, I'll try to figure what exactly it is, but feel free to post this as an answer, I'll mark it as correct as it's working like a charm. Commented Feb 16, 2017 at 14:17

1 Answer 1

1

Install asar locally as a project dependency, cd to your project directory and run:

$ npm install asar --save-dev

Change your npm-script to the following:

"scripts": {
  "create-asar": "node_modules/.bin/asar pack app app.asar"
},

Note: asar is being executed via the local node_modules/.bin folder.

Then run $ npm run create-asar and subsequently check whether it unpacks successfully.

1
  • worked, so it may be something related to another package, or a globally installed package. Thanks mate. Commented Feb 16, 2017 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.