lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.13k stars 1.3k forks source link

sharp not included in a packaged Electron app build with Quasar (yarn 4.3.1, electron-builder, vite) #4136

Closed Dirk- closed 1 week ago

Dirk- commented 4 months ago

Possible install-time or require-time problem

You must confirm both of these before continuing.

Are you using the latest version of sharp?

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

Are you using a supported runtime?

If you cannot confirm any of these, please upgrade to the latest version and try again before opening an issue.

Are you using a supported package manager and installing optional dependencies?

If you cannot confirm any of these, please upgrade to the latest version of your chosen package manager and ensure you are allowing the installation of optional or multi-platform dependencies before opening an issue.

What is the complete error message, including the full stack trace?

There is no error message when I start the program, but sharp is not there. I included the build log instead.

``` (base) dirk@Dirks-Mac-Studio quasar-sharp % quasar build -m electron .d88888b. d88P" "Y88b 888 888 888 888 888 888 8888b. .d8888b 8888b. 888d888 888 888 888 888 "88b 88K "88b 888P" 888 Y8b 888 888 888 .d888888 "Y8888b. .d888888 888 Y88b.Y8b88P Y88b 888 888 888 X88 888 888 888 "Y888888" "Y88888 "Y888888 88888P' "Y888888 888 Y8b Build mode............. electron Pkg quasar............. v2.16.4 Pkg @quasar/app-vite... v1.9.3 Pkg vite............... v2.9.18 Debugging.............. no Publishing............. no App • WAIT • Compiling of Electron UI with Vite in progress... App • DONE • Electron UI compiled with success • 1504ms App • WAIT • Compiling of Electron Main with Esbuild in progress... App • DONE • Electron Main compiled with success • 6ms App • WAIT • Compiling of Electron Preload with Esbuild in progress... App • DONE • Electron Preload compiled with success • 1ms UI files build summary: ╔══════════════════════════════════╤═══════════╗ ║ Asset │ Size ║ ╟──────────────────────────────────┼───────────╢ ║ electron-main.js │ 1.46 KB ║ ║ electron-preload.js │ 0.00 KB ║ ║ assets/ErrorNotFound.0928d832.js │ 0.59 KB ║ ║ assets/IndexPage.fe807f4b.js │ 1.21 KB ║ ║ assets/MainLayout.eb4528f3.js │ 33.11 KB ║ ║ assets/QBtn.d1e54607.js │ 15.82 KB ║ ║ assets/index.9c57cbe8.js │ 102.19 KB ║ ║ assets/render.ffc2effe.js │ 0.31 KB ║ ╟──────────────────────────────────┼───────────╢ ║ assets/index.e1aa5673.css │ 197.24 KB ║ ╟──────────────────────────────────┼───────────╢ ║ package.json │ 0.40 KB ║ ╟──────────────────────────────────┼───────────╢ ║ index.html │ 0.83 KB ║ ╚══════════════════════════════════╧═══════════╝ App • Installing UnPackaged folder production dependencies... App • [sync] Running "yarn workspaces focus --all --production" in /Users/dirk/Projekte/quasar-sharp/dist/electron/UnPackaged ➤ YN0000: · Yarn 4.3.1 ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - 7zip-bin@npm:5.2.0, @babel/code-frame@npm:7.24.7, @babel/highlight@npm:7.24.7, @develar/schema-utils@npm:2.6.5, and 665 more. ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0007: │ sharp@npm:0.33.4 must be built because it never has been before or the last one failed ➤ YN0000: └ Completed in 1s 249ms ➤ YN0000: · Done in 1s 304ms App • WAIT • Bundling app with electron/builder... • electron-builder version=24.13.3 os=23.5.0 • writing effective config file=dist/electron/Packaged/builder-effective-config.yaml • packaging platform=darwin arch=arm64 electron=31.1.0 appOutDir=dist/electron/Packaged/mac-arm64 • skipped macOS application code signing reason=cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, it could cause some undefined behaviour, e.g. macOS localized description not visible, see https://electron.build/code-signing allIdentities= • building target=macOS zip arch=arm64 file=dist/electron/Packaged/Quasar App-0.0.1-arm64-mac.zip • building target=DMG arch=arm64 file=dist/electron/Packaged/Quasar App-0.0.1-arm64.dmg • Detected arm64 process, HFS+ is unavailable. Creating dmg with APFS - supports Mac OSX 10.12+ • building block map blockMapFile=dist/electron/Packaged/Quasar App-0.0.1-arm64.dmg.blockmap • building block map blockMapFile=dist/electron/Packaged/Quasar App-0.0.1-arm64-mac.zip.blockmap App • DONE • electron/builder built the app • 29390ms Build succeeded Build mode............. electron Pkg quasar............. v2.16.4 Pkg @quasar/app-vite... v1.9.3 Pkg vite............... v2.9.18 Debugging.............. no Publishing............. no Browser target......... es2019|edge88|firefox78|chrome87|safari13.1 Node target............ node20 ======================= Output folder.......... /Users/dirk/Projekte/quasar-sharp/dist/electron ```

What is the complete output of running npm install --verbose --foreground-scripts sharp in an empty directory?

``` npm verb cli /usr/local/bin/node /usr/local/bin/npm npm info using npm@10.5.0 npm info using node@v20.12.1 npm verb title npm install sharp npm verb argv "install" "--loglevel" "verbose" "--foreground-scripts" "sharp" npm verb logfile logs-max:10 dir:/Users/dirk/.npm/_logs/2024-06-27T12_49_37_278Z- npm verb logfile /Users/dirk/.npm/_logs/2024-06-27T12_49_37_278Z-debug-0.log npm http fetch GET 200 https://registry.npmjs.org/sharp 9ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-ia32 246ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm 248ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-wasm32 265ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm 276ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-s390x 695ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-s390x 1203ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@emnapi%2fruntime 167ms (cache revalidated) npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-win32-ia32 npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-wasm32 npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@emnapi/runtime npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-linux-s390x npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-linux-arm npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-libvips-linux-s390x npm verb reify failed optional dependency /Users/dirk/Projekte/quasar-sharp/node_modules/@img/sharp-libvips-linux-arm npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 216ms up to date, audited 693 packages in 2s 127 packages are looking for funding run `npm fund` for details found 0 vulnerabilities npm verb exit 0 npm info ok ```

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: macOS 14.5
    CPU: (24) arm64 Apple M2 Ultra
    Memory: 15.79 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.1 - /usr/local/bin/node
    Yarn: 4.3.1 - ~/.yarn/bin/yarn
    npm: 10.5.0 - /usr/local/bin/npm

What I did

I put up a sample project to demonstrate the issue. I managed to get Quasar work with yarn v4. I edited the electron-builder options in quasar.config.js according to the sharp instructions, I used the supportedArchitectures option in .yarnrc.yml. Since then the error shown when starting the packaged app is gone, but sharp does nothing. I noticed YN0007 in the build log above, but I do not know how to overcome this.

The dev version runs the short sharp test fine.

There is some information on vite handling on the Quasar website which can possibly combined with the sharp information, but I don't know how.

I only see instructions on how to unpack or exclude sharp from bundling, but how will it get into the packaged app?

I am sure I am just missing a trivial thing, but I do not know which...

lovell commented 1 week ago

Sorry, I think I missed this one at the time. Is this still a problem? I notice the linked repo readme says: "Updated a few packages, including quasar, electron and sharp -> now it works ¯(ツ)/¯".

Dirk- commented 1 week ago

Sorry, I think I missed this one at the time. Is this still a problem? I notice the linked repo readme says: "Updated a few packages, including quasar, electron and sharp -> now it works ¯(ツ)/¯".

Thanks for asking, but the problem is gone now, indeed :)