opencv4nodejs: new Error('library dir does not exist: ' + libDir)
Hello, I have been trying to install opencv4nodejs on MacOS Mojave with npm i opencv4nodejs and it keeps giving me this error:
npm ERR! code 1
npm ERR! path /Users/u/trr/node_modules/opencv4nodejs
npm ERR! command failed
npm ERR! command sh -c node ./install/install.js
npm ERR! info install using lib dir: /Users/u/trr/node_modules/opencv-build/opencv/build/lib
npm ERR! /Users/u/trr/node_modules/opencv4nodejs/install/install.js:37
npm ERR! throw new Error('library dir does not exist: ' + libDir)
npm ERR! ^
npm ERR!
npm ERR! Error: library dir does not exist: /Users/u/trr/node_modules/opencv-build/opencv/build/lib
npm ERR! at Object.<anonymous> (/Users/u/trr/node_modules/opencv4nodejs/install/install.js:37:9)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1092:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:972:32)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:813:14)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
npm ERR! at node:internal/main/run_main_module:17:47
Have tried so many things but it just wouldn’t work. Would be great if someone can help me with this.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15
npm i -g npm@6npm i opencv4nodejs --savenpm i -g npm@latestbrew updatebrew install opencv@4brew link --force opencv@4!!!NOTE!!! Please change the opencv version to fit your installation in step 3.
export OPENCV4NODEJS_DISABLE_AUTOBUILD=1export OPENCV_LIB_DIR=/opt/homebrew/Cellar/opencv/4.5.5_3/libexport OPENCV_BIN_DIR=/opt/homebrew/Cellar/opencv/4.5.5_3/binexport OPENCV_INCLUDE_DIR=/opt/homebrew/Cellar/opencv/4.5.5_3/include/opencv4npm install -g opencv4nodejsDon’t know how it works on Mac. Just install / build plain opencv. Make links in
package.json, like mine, but with your paths:Then
npm i opencv4nodejs --save@74staz You might try this steps: https://github.com/justadudewhohacks/opencv4nodejs/issues/775#issuecomment-804347861
It will help you solve a lot. And then if your OpenCV installation is correct and matched opencv4nodejs version, than it will build fully. But quickly, you can just disable auto build in terminal with :
export OPENCV4NODEJS_DISABLE_AUTOBUILD=1. And after you will build it yourself.@staz9 then you are very close to it. But you need a bit of easy hacks like I did. First, forget about OpenCV version 4.5.1, that causes the Multitracker error, that has been moved to another directory and that this package did not know about this change.
With version 4.5.0, not Multitracker error, but you’ll get SIFT error for sure in both versions. So as a hack, you will have to comment out 2 or 3 lines of code in modules source code to tell it to ignore the SIFT feature, which is now private and removed. Alternative for SIFT is SURF and 2 others. You will find SURF for sure, not sure for the 2 others. SURF is said to be faster in most use cases. And chances are you’re not even gonna use any of them in your project. I didn’t need their calculation, but SURF is still available.
You can follow this Issue https://github.com/justadudewhohacks/opencv4nodejs/issues/805 , I showed every step you need to do from where you are right now, after Tracking error. And you’ll get it done.