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.

Electron app with Sharp yields [Error: VipsOperation: class "heifsave" not found] at runtime on Linux

See original GitHub issue

Did you see the documentation relating to installation? Yes

Have you ensured the architecture and platform of Node.js used for npm install is the same as the architecture and platform of Node.js used at runtime? Yes

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest? Yes. sharp@0.29.2

If you are using npm v6 or earlier and installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag? N/A

If you are using npm v7, does the user running npm install own the directory it is run in? yes

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag? N/A

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?

out.txt

What is the output of running npx envinfo --binaries --system?

  System:
    OS: Linux 5.14 Fedora Linux 35 (KDE Plasma)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 9.63 GB / 62.73 GB
    Container: Yes
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 16.3.0 - ~/.nvm/versions/node/v16.3.0/bin/node
    npm: 7.15.1 - ~/.nvm/versions/node/v16.3.0/bin/npm

Problem

I try to add sharp to my electron project and use it only in the main process. I am using Nextron which use electron-builder in background.

Everything works properly when running in dev mode. But when I build the program which use electron-builder internally. It yields following error.

When I put sharp as a dev dependency, it will yeild error reports in #2716 during runtime which make sense as it is mark as dev. Then. when I make it as dependency, in the runtime, it will yeilds [Error: VipsOperation: class "heifsave" not found] when I am calling await sharpInstance.resize({ height: 360 }).avif().toFile(imageCachePath);.

I add the line to webpack configs as mentioned here. I have also try electron-rebuild but does not fix my problem.

I have also run electron-builder install-app-deps to rebuild the native dependencies which print following logs.

  • rebuilding native dependencies  dependencies=sharp@0.29.2 platform=linux arch=x64
  • install prebuilt binary  name=sharp version=0.29.2 platform=linux arch=x64 napi=

I wonder what the cause is in this case ? Thank you very much.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
zluo01commented, Nov 7, 2021

It seems like electron-builder ignore linux. For who comes with this similar issues the following is the solution. https://github.com/electron-userland/electron-builder/issues/6200#issuecomment-907830847

0reactions
lovellcommented, Nov 7, 2021

Please make sure you’re using the latest version of electron-builder as I believe are quite a few bugs relating to native modules that use Node-API (such as sharp) that have recently been fixed.

Some of the Electron tooling, and I think electron-builder falls into this category, ignores the install script that sharp defines and instead assumes all native modules only require node-gyp. There’s a good summary of this at https://github.com/lovell/sharp/issues/2764#issuecomment-871716837

You might get better results by running rm -rf node_modules/sharp && npm install sharp after electron-builder has run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to generated the installers of electron app for windows ...
I'm using electron-builder through the electron-vue lib (https://github.com/SimulatedGREG/electron-vue). And following the instructions to ...
Read more >
app | Electron
Control your application's event lifecycle.
Read more >
Auto Update - electron-builder
macOS application must be signed in order for auto updating to work. ... Mac, otherwise latest-mac.yml cannot be created, which causes autoUpdater error....
Read more >
Electron packager tutorial - Christian Engvall
In this electron packager tutorial we will look at how to create MacOS, Windows and Linux executables with an app icon.
Read more >
electron-packager - npm
Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI. Latest version: 17.1.1, last published: 2 ...
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