Search code examples
electronelectron-builderexiftool

exiftool-vendored doesn't return when used in an electron app on Mac?


On Mac, when I run my app from WebStorm, exiftool-vendored works great. However, when I build my app (I use electron-builder) and install it on the same Mac, it never returns, even just trying to get the version:

exiftool.version().then(version => writeBreadcrumb('exif', version))

In other words, no error is raised, and the then is never executed when running an installed version of my app, though it works fine running my app from WebStorm (with cd build && electron .)

What am I doing wrong? Is there an example anywhere of how to use exiftool-vendored in an electron app?


Solution

  • You should take a look at what the docs say about making it work with Electron:

    How do you make this work with electron?

    Electron is notoriously brittle and buggy, and is not officially supported by this package. Although PhotoStructure uses this package within electron, there's a nontrivial amount of auxiliary support code specific to that project to make it work smoothly.

    If you're still anxious to try, here are some things to keep in mind:

    1. Note that this package will spawn exiftool external processes, which means the exiftool-vendored.pl and exiftool-vendored.exe packages should be included in your asarUnpack. SmartUnpack might work, but if it doesn't use a pattern like node_modules/{exiftool-vendored.*}/**/*.

    2. If you're requiring exiftool-vendored from within a webview, you're gonna have a bad time. Many things won't work due to a lack of node compatibility within electron.

    3. __dirname at runtime from within an asar package after webpacking will be invalid, so don't rely on that.

    https://github.com/photostructure/exiftool-vendored.js/wiki/FAQ#how-do-you-make-this-work-with-electron