justadudewhohacks/opencv4nodejs

opencv4nodejs not installing with "library dir does not exist" error

christopheryeemonbymason opened this issue · 7 comments

Error Message

christopheryeemon@system76-pc:~$ npm i -g opencv4nodejs
npm ERR! code 1
npm ERR! path /home/christopheryeemon/.nvm/versions/node/v12.16.2/lib/node_modules/opencv4nodejs
npm ERR! command failed
npm ERR! command sh -c node ./install/install.js
npm ERR! info install using lib dir: /home/christopheryeemon/.nvm/versions/node/v12.16.2/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib
npm ERR! /home/christopheryeemon/.nvm/versions/node/v12.16.2/lib/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: /home/christopheryeemon/.nvm/versions/node/v12.16.2/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib
npm ERR!     at Object.<anonymous> (/home/christopheryeemon/.nvm/versions/node/v12.16.2/lib/node_modules/opencv4nodejs/install/install.js:37:9)
npm ERR!     at Module._compile (internal/modules/cjs/loader.js:1156:30)
npm ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
npm ERR!     at Module.load (internal/modules/cjs/loader.js:1000:32)
npm ERR!     at Function.Module._load (internal/modules/cjs/loader.js:899:14)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
npm ERR!     at internal/main/run_main_module.js:18:47

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/christopheryeemon/.npm/_logs/2021-06-25T22_50_09_267Z-debug.

OpenCV version (example 3.4.1): 5.6.0

With OpenCV-contrib? (extra modules): no

OS: Ubuntu 20.04.2 LTS

Can this issue get attention from contributors, please?

yes I also get same issue on here

koush commented

Run this per the instructions:

export OPENCV4NODEJS_DISABLE_AUTOBUILD=1

I get the same issue even when running with the export command above

If you are running on a Unix system you could try to compile your own opencv that's pretty straight forward.
You can place the whole folder on the root of your node project and add to package.json the following:

"opencv4nodejs": {
    "disableAutoBuild": 1,
    "opencvIncludeDir": "../../opencv/include",
    "opencvLibDir": "../../opencv/lib",
    "opencvBinDir": "../../opencv/bin"
  }

While digging a little further into this issue I also found out that the logic for finding the opencv build is specific to windows, see this line: https://github.com/justadudewhohacks/opencv4nodejs/blob/master/lib/cv.js#L45

where process.env.path is found on windows, for unix systems its process.env.PATH, this could be fixed with little effort but the part that puzzle's me is that on the same catch block (and without really changing the requirePath) it goes on to call the same path that triggered the catch block to begin with, see this line: https://github.com/justadudewhohacks/opencv4nodejs/blob/master/lib/cv.js#L58

@justadudewhohacks could you please get linux users some help please?

I'm also having this error. Windows 10. Nodejs version 16.13.1. No idea what to do with export OPENCV4NODEJS_DISABLE_AUTOBUILD=1

I don't understand why but after installing node-gyp it works.

apt-get install --save node-gyp