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.23k stars 1.29k forks source link

Could not load the "sharp" module using the darwin-arm64 runtime #4122

Closed thevarunaditya closed 5 months ago

thevarunaditya commented 5 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?

Uncaught Exception:
Error: Could not load the "sharp" module using the darwin-arm64 runtime
ERR_DLOPEN_FAILED: dlopen(/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/.com.varunaditya.sparxsolver.e2pyJT, 0x0001): Library not loaded: @rpath/libvips-cpp.42.dylib
Referenced from: <7F2BDEAF-DCCB-3164-A100-A90094C453FD> /private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/.com.varunaditya.sparxsolver.e2pyJT
Reason: tried: '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../sharp-libvips-darwin-arm64/1.0.2/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../../../@img-sharp-libvips-darwin-arm64-npm-1.0.2-6c9ede770e/node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../sharp-libvips-darwin-arm64/1.0.2/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/private/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/../../../../../@img-sharp-libvips-darwin-arm64-npm-1.0.2-6c9ede770e/node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.42.dylib' (no such file), '/Users/varunaditya/Desktop/Spakes/SparxMaths-Solver/build/mac-arm64/SparxMaths-Solver.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libvips-cpp.42.dylib' (no such file), '/Users/varunaditya/Desktop/Spakes/SparxMaths-Solver/build/mac-arm64/SparxMaths-Solver.app/Contents/Frameworks/libvips-cpp.42.dylib' (no such file)

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

npm verbose cli /Users/varunaditya/.nvm/versions/node/v18.20.3/bin/node /Users/varunaditya/.nvm/versions/node/v18.20.3/bin/npm
npm info using npm@10.7.0
npm info using node@v18.20.3
npm verbose title npm install sharp
npm verbose argv "install" "--loglevel" "verbose" "--foreground-scripts" "sharp"
npm verbose logfile logs-max:10 dir:/Users/varunaditya/.npm/_logs/2024-06-02T08_29_40_122Z-
npm verbose logfile /Users/varunaditya/.npm/_logs/2024-06-02T08_29_40_122Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/sharp 10ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/detect-libc 142ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/color 146ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/semver 150ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-arm64 813ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-x64 869ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-x64 881ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm64 1100ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-arm64 997ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-arm64 1197ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-s390x 1205ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm 1226ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm 1105ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-x64 1257ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-x64 1115ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-x64 695ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm64 1073ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-s390x 1036ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-x64 1120ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-arm64 1000ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-ia32 1082ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-wasm32 1122ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-x64 1096ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/color-convert 45ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/color-string 56ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/@emnapi%2fruntime 1066ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/tslib 79ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/simple-swizzle 50ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/color-name 54ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/color-name 68ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/is-arrayish 57ms (cache revalidated)
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-win32-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-win32-ia32
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-wasm32
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@emnapi/runtime
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/tslib
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linuxmusl-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linuxmusl-arm64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linux-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linux-s390x
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linux-arm64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-linux-arm
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linuxmusl-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linuxmusl-arm64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linux-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linux-s390x
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linux-arm64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-linux-arm
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-libvips-darwin-x64
npm verbose reify failed optional dependency /Users/varunaditya/empty/node_modules/@img/sharp-darwin-x64
npm info run sharp@0.33.4 install node_modules/sharp node install/check

> sharp@0.33.4 install
> node install/check

sharp: Detected globally-installed libvips v8.15.2
sharp: Attempting to build from source via node-gyp
sharp: Please add node-addon-api to your dependencies
npm info run sharp@0.33.4 install { code: 0, signal: null }

added 11 packages in 5s

3 packages are looking for funding
  run `npm fund` for details
npm verbose exit 0
npm info ok

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

  System:
    OS: macOS 14.4
    CPU: (12) arm64 Apple M3 Pro
    Memory: 69.56 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.3 - ~/.nvm/versions/node/v18.20.3/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
lovell commented 5 months ago

There are a couple of things happening here.

sharp: Detected globally-installed libvips v8.15.2 sharp: Attempting to build from source via node-gyp sharp: Please add node-addon-api to your dependencies

This suggests you might be attempting to use a globally-installed libvips with sharp. If this is the case, please see https://sharp.pixelplumbing.com/install#building-from-source for more information about the requirements.

ERR_DLOPEN_FAILED: dlopen(/var/folders/q1/09rs6v5d03b20kqwggc4dllm0000gn/T/.com.varunaditya.sparxsolver.e2pyJT, 0x0001): Library not loaded: @rpath/libvips-cpp.42.dylib

This suggests you might be using a JavaScript bundler such as Webpack. If this is the case, please see https://sharp.pixelplumbing.com/install#bundlers for more information about how to indicate that sharp should be treated as an "external" package.

radekzz commented 5 months ago

I experience Error: Could not load the 'sharp' module using the linux-x64 runtime using 0.33.4 on Firebase cloud functions

lovell commented 5 months ago

@monohuman Were you able to make any progress with this?

thevarunaditya commented 5 months ago

No, I just used a different library and it worked.

On Thu, Jun 13, 2024 at 4:49 PM Lovell Fuller @.***> wrote:

@monohuman https://github.com/monohuman Were you able to make any progress with this?

— Reply to this email directly, view it on GitHub https://github.com/lovell/sharp/issues/4122#issuecomment-2165899964, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASUBMK7MHM55C7U4YQUQD43ZHGWQLAVCNFSM6AAAAABIU3XNIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRVHA4TSOJWGQ . You are receiving this because you were mentioned.Message ID: @.***>

lovell commented 5 months ago

Progress of a different kind ;)

Thanks for the update - I'll close.

frncki commented 3 weeks ago

Hey! For anyone who stumbles across this problem as I did. The solution that worked for me was to add sharp to excluded packages in my bundler configuration, as I had forgotten to do this step. https://sharp.pixelplumbing.com/install#bundlers Have a nice day :)