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.31k stars 1.3k forks source link

cannot load sharp module #4265

Closed suman-webgendev closed 1 week ago

suman-webgendev commented 1 week ago

Hi, I'm trying to use sharp in a deno project to create a cli app to optimize images for my hobby project. It is working flawlessly on the dev serve, but as soon as I build the executable i got the following error.

error: Uncaught (in promise) Error: Could not load the "sharp" module using the darwin-x64 runtime
undefined: dlopen(/var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/@img/sharp-darwin-x64/0.33.5/lib/sharp-darwin-x64.node, 0x0001): tried: '/var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/@img/sharp-darwin-x64/0.33.5/lib/sharp-darwin-x64.node' (no such file)
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=darwin --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (file:///var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/sharp.js:113:9)
    at Object.<anonymous> (file:///var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/sharp.js:116:4)
    at Module._compile (node:module:745:34)
    at Object.Module._extensions..js (node:module:762:10)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:818:16)
    at Object.<anonymous> (file:///var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/constructor.js:10:1)
    at Object.<anonymous> (file:///var/folders/8_/637l6qms7k32y6d6dyb72cdh0000gp/T/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/constructor.js:454:4)

first I thought it is a mac issue but I got the same error on linux as well

error: Uncaught (in promise) Error: Could not load the "sharp" module using the linux-x64 runtime
undefined: /tmp/deno-compile-img-tool/.deno_compile_node_modules/localhost/@img/sharp-linux-x64/0.33.5/lib/sharp-linux-x64.node: cannot open shared object file: No such file or directory
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (file:///tmp/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/sharp.js:113:9)
    at Object.<anonymous> (file:///tmp/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/sharp.js:116:4)
    at Module._compile (node:module:745:34)
    at Object.Module._extensions..js (node:module:762:10)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:818:16)
    at Object.<anonymous> (file:///tmp/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/constructor.js:10:1)
    at Object.<anonymous> (file:///tmp/deno-compile-img-tool/.deno_compile_node_modules/localhost/sharp/0.33.5/lib/constructor.js:454:4)

If you know how to fix the issue, plese help me out with it. Thank you.

lovell commented 1 week ago

Please see https://github.com/lovell/sharp/issues/3912