sharp: Sharp Module Installation Error: Library not loaded: @rpath/libvips-cpp.42.dylib
Hello,
I am really new at using Sharp and I was trying to install and run it for my app. I plan on using it to composite multiple images together.
The problem I am running into is after I do npm install sharp and in one of the files i have const sharp = require('sharp') run the app, I see:
`Something went wrong installing the “sharp” module dlopen(/Users/…/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: @rpath/libvips-cpp.42.dylib Referenced from: /Users/…/node_modules/sharp/build/Release/sharp.node Reason: Incompatible library version: sharp.node requires version 54.0.0 or later, but libvips-cpp.42.dylib provides version 51.0.0
- Remove the “node_modules/sharp” directory, run “npm install” and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues `
I tried performing each of the steps but no luck. Also tried going here and installing this via homebrew https://libvips.github.io/libvips/install.html
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 19 (9 by maintainers)
Ok I found the problem. It was that I have some dependencies installed which also have sharp as a dependency. So two different versions of sharp were in my
node_modulesdirectory. (FYI I’m using yarn workspaces)In my case it was
gatsby-plugin-manifestand@fiahfy/icns-convertwhich are both using sharp0.23.4.I was experiencing an unsupported image format error, with a regular PNG file that used to be working before.
Error: Input file contains unsupported image format (via gatsby-plugin-manifest)Turns out there was some conflict between
sharpandlibvipsversion frombrew(macOS).What worked for me was forcing sharp to re-install with the bundled libvips.
@MMA15 give it a try if on macOS, it may help.
Update: The problem is dependent of the import order of the library.
Does not work
Works
Example repository: https://github.com/sapkra/sharp-issue-2029