Search code examples
node.jsmacosopencvjpeghomebrew

OpenCV: Library not loaded: libjpeg.8.dylib


This error with OpenCV (I'm trying to use Node + OpenCV - as in node-opencv) has been driving me crazy. I've looked at many answers on StackOverflow or otherwise, and I think this could be a problem with the upgraded Homebrew or maybe with OpenCV. Unless it is a problem with the way I imported OpenCV.

Does anyone understand this/know what to do?

module.js:598
  return process.dlopen(module, path._makeLong(filename));
                 ^
Error: dlopen(/Users/Joe/SRS/node_modules/opencv/build/opencv/v6.0.0/Release/node-v51-darw
in-x64/opencv.node, 1): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
  Referenced from: /usr/local/opt/opencv/lib/libopencv_highgui.2.4.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/Joe/SRS/node_modules/opencv/lib/bindings.js:4:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

Solution

  • I was getting the same error and reinstalling Open CV fixed it. I ran brew reinstall --build-from-source opencv.