question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get `asar-unpack` to work

See original GitHub issue

Our Electron app uses convert from ImageMagick, and that needs some .xml files alongside the binary. Our electron folder ends up looking like this:

public/
β”œβ”€β”€ external/
β”‚Β Β  β”œβ”€β”€ colors.xml
β”‚Β Β  β”œβ”€β”€ convert
β”‚Β Β  β”œβ”€β”€ delegates.xml
β”‚Β Β  └── magic.xml
β”œβ”€β”€ app.css
β”œβ”€β”€ app.js
β”œβ”€β”€ electron-main.js
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
└── vendor.js

I’m able to run asar pack public/ public.asar --unpack 'public/external/*' and get both public.asar and public.asar.unpacked, but I cannot for the life of me figure out the path to be passed via build.asar-unpack in the development package.json.

I’ve tried …

  "build": {
    "asar-unpack": "public/external/*"
  }
  "build": {
    "asar-unpack": "external/*"
  }
  "build": {
    "asar-unpack": "app/external/*"
  }
  "build": {
    "asar-unpack": "*/external/*"
  }
  "build": {
    "asar-unpack": "dist/ProductName-darwin-x64/Electron.app/Contents/Resources/app/external/*"
  }

… But am not able to get app.asar.unpacked. Is there anything I’m missing?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
whyboriscommented, Feb 15, 2018

Thank you @mikew for also sharing your answer. In 2018 this worked:

"mac": {
  ...
  "target": "dmg",
  "asar": true,
  "asarUnpack": [
    "../node_modules/@ffmpeg-installer"
  ]
}

Successfully get this once the dmg is installed:

contents/
β”œβ”€β”€ Resources/
β”‚   β”œβ”€β”€ app.asar
β”‚   └── app.asar.unpacked/
β”‚       └── node_modules/
β”‚           └── @ffmpeg-installer/

Now the tricky part is referring to it from within your app :trollface: This hazardous workaround seems to work with basically 1 line of code: https://github.com/electron/electron/issues/6262#issuecomment-273312942

3reactions
mikewcommented, May 11, 2016

Ah, figured it out. Using a globstar works, and no matter your directory structure, your files will be under app/. The following works:

  "build": {
    "asar-unpack": "**/app/external/*"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my electron app doesn't launch after packaging?
To me it looks like that your build does include native addons (*.node). In electron-packager the solution was to add the asar unpack...
Read more >
PlatformSpecificBuildOptions - electron-builder
Node modules, that must be unpacked, will be detected automatically, you don't need to explicitly set asarUnpack - please file an issue if...
Read more >
ASAR Archives - Electron
The archives can not be modified so all Node APIs that can modify files will not work with ASAR archives. Working Directory Can...
Read more >
Application Packaging | Electron
Most users will get this feature for free, since it's supported out of the box by ... Working Directory Can Not Be Set...
Read more >
Can't launch ffmpeg in sandboxed electron app
//Get the paths to the packaged versions of the binaries we want to use. var ffmpegPath = require('ffmpeg-static-electron').path;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found