auto build broken with Node.js 15.7.0 and Windows 10
lemoun opened this issue · 6 comments
opencv4nodejs v5.6.0 auto build installation seems broken with Node.js current version (15.7.0) and Windows 10. It throws the message ' throw new Error('no OpenCV libraries found in lib dir: ' + libDir)'. It works with earlier versions, at least up until v14.15.4.
Yea, getting this same with fresh npm install of the thing. The issue seems to be that it fails on this, but somehow creates the libraries still with CMake, then if you run it again, it will do a) clean up, removes those libraries or b) fails on renaming original directory to ".opencv4nodejs...blah" directory, as there that temp directory seems to get stuck hanging. I have not found a workaround on this so far.
Once I could install it to local path though with --save (with some weird hackery I did with copy/paste the /lib folder and what not), but I would like to have it installed with -g (that I cannot get done'd)
It seems to be related to the new automatic peer dependencies installation of npm 7. Try to disable it with the --legacy-peer-deps
flag.
okay, here is what I tried:
1st: trying to install freshly with command npm (I assumed lemoun you meant npm, not nvm)
npm install -g --legacy-peer-deps
--> what this does is that it complains about missing libdir as the installer seems to continue before libraries are built with CMake
--> this resulted in Error + having temporary folder \npm\node_modules.opencv4nodejs-kbWywpbV
2nd: Now that the libraries were there, I I tried again the same command
--> the temporary folder blocks the install, because it can't rename the original folder to the temporary one as it's existing?
3rd: I removed temporary folder and tried once more again (libraries still there)
--> CleanUp process removes the libraries, then complains them not being found and results the same as in 1st try
4th: Once again with libraries already there, I tried to:
clean away the temporary folder
restart the cmdline in admin mode
set OPENCV4NODEJS_DISABLE_AUTOBUILD=1
set OPENCV_LIB_DIR=C:/Users//AppData/Roaming/npm/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib/Release
and finally run the:
npm i -g --legacy-peer-deps opencv4nodejs
--> Now it did not do the cleanup (libraries did not get lost), but it still complaining that the library dir is missing:
npm ERR! C:\Users<username>\AppData\Roaming\npm\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: C:/Users//AppData/Roaming/npm/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib/Release
npm ERR! at Object. (C:\Users<username>\AppData\Roaming\npm\node_modules\opencv4nodejs\install\install.js:37:9)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1108:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:973: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
RESULT: there seems to be multiple issues here:
- The script has error about the missing libraries before CMake can build them
- When libraries are there, the install script with Disable Autobuild False setup does cleanup for the libraries that were build and complain once again that there are no, gives error, cmake builds them meanwhile, but the installation fails
- When libraries are there, the install script with Disable Autobuild True setup seems to still not find the libraries
At the end, even I tried many different combinations as described earlier --> The install script just could not complete
This whole issue can be fixed/workaround via downgrading npm to latest of the 6.xx.xx version.
I was testing this together with Zoomla library in Robot Framework. However, while the tests needed Appium involved, when using image locator, the keywords doing the "click" could not click the located element. It was "clicking" on the right spot, but the actions were not LMB, instead they seem to be "emulated touch events of some sort", which of course my application do not support. The test was just "touching" that correct position located, but none of the actions did the necessary "button-click"
Thanks for this workaround. For now, I will just stick with node version 14 and npm version 6. A fix would require to make opencv4nodejs peer dependencies compliant with npm 7 specifications. Unfortunately, I can't find much resources around.
Indeed seems like npm@7 broke it and not just on Windows. It appears that npm@7 runs install
hook before dependencies are installed which means opencv4nodejs
can't find OpenCV library that has to be build by opencv-build
dependency. Hence the simple fix to make it work with npm@7 is to install in two steps:
$ npm install opencv-build
$ npm install opencv4nodejs
Or at least that works for me. Doesn't help when you need to put opencv4nodejs
in dependencies
though.