Electron app with Sharp yields [Error: VipsOperation: class "heifsave" not found] at runtime on Linux
See original GitHub issueDid 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?
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
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
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 theinstall
script that sharp defines and instead assumes all native modules only requirenode-gyp
. There’s a good summary of this at https://github.com/lovell/sharp/issues/2764#issuecomment-871716837You might get better results by running
rm -rf node_modules/sharp && npm install sharp
afterelectron-builder
has run.