Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 % 
like image 818
Vanka Manikanth Avatar asked Nov 05 '25 08:11

Vanka Manikanth


1 Answers

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!

like image 78
Vanka Manikanth Avatar answered Nov 06 '25 23:11

Vanka Manikanth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!