A repository meant to reproduce an error while using and packing sharp library in an Electron App with Vite.
The repo features a dummy 'renderer' part, which is not important for this issue (but if you see it, it means that the app works)
The electron main process uses the sharp library to resize an image (media/Lenna-in.png ==> media/Lenna-out.png). The app is supposed to launch the resizing as soon as it is launched. If everyting goes well, the 'Lenna-out.png' file should pop in the media folder, when you start the app.
- The expected behaviour works perfectly fine in dev mode on Linux:
npm run dev:electron
-
This works also perfectly fine in production mode on Linux with
npm run build:electron
and the run the app withdist/electron/Packaged/Quasar\ Electron\ App\ with\ sharp-linux-x64/Quasar\ Electron\ App\ with\ sharp
-
The problem occurs when launching the Windows build, as the module
sharp-win32-x64
is not resolved. When launching the app by double-clicking the icon, it fails with an error message and doesn't event launch the GUI part.
The error message : Could not load the "sharp" module using the win32-x64 runtime
- There is a npm issue, making it difficult to get the
sharp-win32-x64
deployed alongside the other platform libs. However even ifsharp-win32-x64
is manually copied to the build folder (where I guess it should be normally), it is not resolved either. That is the purpose of the&& cp ...
part in thebuild:electron
script inpackage.json
yarn
# or
npm install
npm run dev:electron
npm run build:electron