Sharp: failing to intilaize Sharp on OSX

Created on 10 Apr 2017  路  6Comments  路  Source: lovell/sharp

On a updated node (7.8.0) and up to date giflib (5.1.4) in OSX (10.12.4) I get the following error when I attempt to start my node app that utilizes the latest Sharp (0.17.3):

module.js:598
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen(/Users/jasonsperske/git/test_app/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: /usr/local/opt/giflib/lib/libgif.4.dylib
  Referenced from: /usr/local/opt/vips/lib/libvips-cpp.42.dylib
  Reason: image not found
    at Object.Module._extensions..node (module.js:598:18)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/jasonsperske/git/test_app/node_modules/sharp/lib/constructor.js:8:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/jasonsperske/git/test_app/node_modules/sharp/lib/index.js:3:15)
    at Module._compile (module.js:571:32)

I was able to work around this by adding the following symbolic link:

ln -s /usr/local/opt/giflib/lib/libgif.7.dylib /usr/local/opt/giflib/lib/libgif.4.dylib
question

Most helpful comment

Worked perfectly! Now I have to figure out why I at one point felt the need to brew install vips :)

All 6 comments

Hello, it looks like you're using a global version of vips installed via brew - if so please see https://github.com/jcupitt/libvips/issues/636

Should I redirect this feedback to the vips project? I tried to apply the linked suggestion and the issue persists Here are the steps I tried from the linked topic:

First I removed the symbolic link

rm /usr/local/opt/giflib/lib/libgif.4.dylib

Then I ran the brew command:

$ brew install --build-from-source vips
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/science).
No changes to formulae.

Warning: homebrew/science/vips-8.4.5 already installed

Then I removed my node_modules folder, reran npm update and started the app and got the same error.

If you don't need a custom installation of vips then you can brew uninstall vips, remove node_modules/sharp then npm i and sharp will install its own prebuilt version.

Worked perfectly! Now I have to figure out why I at one point felt the need to brew install vips :)

Thanks for confirming, I'll close this as I think the original problem relates to homebrew and/or giflib.

@jasonsperske I did brew install vips to get MozJPEG compression. Maybe you did it for the same reason.?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Andresmag picture Andresmag  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments

natural-law picture natural-law  路  3Comments

iq-dot picture iq-dot  路  3Comments

knoxcard picture knoxcard  路  3Comments