'npm install opencv4nodejs error on mac m1 bigSur
I have been trying to install opencv4nodejs package with npm install opencv4nodejs
command. But unfortunately the below is being thrown. Have done some research and done few tweaks, but all those doesn't worked.
Below is the error:
manikanthvanka@Manikanths-MacBook-Pro react-file-upload-master % npm install opencv4nodejs
> [email protected] install /Users/manikanthvanka/Downloads/react-
file-upload-master/node_modules/opencv-build
> node ./install.js
info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set
info install skipping auto build...
> [email protected] install /Users/manikanthvanka/Downloads/react-
file-upload-master/node_modules/opencv4nodejs
> node ./install/install.js
info install OPENCV_LIB_DIR is not set, looking for default lib dir
info install using lib dir: /usr/local/lib
/Users/manikanthvanka/Downloads/react-file-upload-
master/node_modules/opencv4nodejs/install/install.js:45
throw new Error('no OpenCV libraries found in lib dir: ' + libDir)
^
Error: no OpenCV libraries found in lib dir: /usr/local/lib
at Object.<anonymous> (/Users/manikanthvanka/Downloads/react-file-
upload-master/node_modules/opencv4nodejs/install/install.js:45:9)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
npm WARN @tinymce/[email protected] requires a peer of
react@^17.0.1 but none is installed. You must install peer
dependencies yourself.
npm WARN @tinymce/[email protected] requires a peer of react-
dom@^17.0.1 but none is installed. You must install peer
dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] - 3 but
none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.16.1 but n.
one is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >=
3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >=
3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none
is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node ./install/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/manikanthvanka/.npm/_logs/2021-03-
07T11_03_42_873Z-debug.log
manikanthvanka@Manikanths-MacBook-Pro react-file-upload-master %
Solution 1:[1]
try do this
$ export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
$ npm i opencv4nodejs
Solution 2:[2]
Step 1 : Find the opencv lib location on your mac using this below command
find / -name "OpenCVConfig.cmake"
Step 2 : Gives you the below path
/opt/homebrew/Cellar/opencv/4.5.2_4/lib
Step 3 : Open zshrc file
open ~/.zshrc
Step 4 : Place the below line in zshrc file
export OPENCV_LIB_DIR="/opt/homebrew/Cellar/opencv/4.5.2_4/lib"
Step 5 : Save & Close the zshrc file Step 6 : Execute below command
source ~/.zshrc
Step 7 : Now try to do npm i opencv4nodejs
Cheers!
Solution 3:[3]
Ok so I was able to get the full installation of opencv4nodejs working. I needed to downgrade node from version 16 to version 14 and do a little bit of compiler option digging!
Current Setup
macOS Big Sur v11.6.1
Homebrew 3.3.2
opencv 4.5.3_2
node v14.18.1
Node installation (with Homebrew)
brew install node@14
opencv installation (with Homebrew)
brew install opencv
opencv4nodejs installtion (with node installer)
- Before installing set both the following compiler flags
export CXXFLAGS="-std=c++14 -Wno-c++11-narrowing" - In the same terminal where you have set the above environment variables run the installation
npm install opencv4nodejs
Solution 4:[4]
I had the same problem and I did solve the issue with the following steps.
First all of. I checked the npm version, for this case I recommend you updated or pass your software resources at the next version.
NodeJs version: 14.16.0. You can verify the version with this command if you had another NodeJs version installed
node --version
Npm version: 6.4.11 You need verify if you had this version installed only you will able to validate this if you have NodeJs but if you didn't have node you can install the version I recommend you
npm --version
After you set the NodeJs and npm versions you need to verify the following things
- Have visual studio 2015 or latest with the development for desktop component
- Have cmake program installed
- Have git bash
- Have Java or the language you will to work
- Have the environment variables for the above programs I mentioned
OpenCv installation
Then you can try again to install open Cv
You need to reopen another or new terminal and then you will execute this command
npm install --save openc4nodejs
And then
npm install -g openc4nodejs
After than or before don't forget to install appium I recommend you 1.19.1 version
You can verify if you have appium with opencv with open Cv doctor you can run appium-doctor
and check if the Open cv component are present.
For to install appium doctor you can run this command, npm install -g appium-doctor
I hope this answers will be helpful for you
Autor: Eder Carbonero
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Vanka Manikanth |
Solution 3 | Dave Bourbeau |
Solution 4 | eventsequor |