justadudewhohacks/opencv4nodejs

SOLVED macOS Installation issues.

EdoTrotta opened this issue · 5 comments

ERROR:

Error: Cannot find module '/Users/yourName/Desktop/project2/node_modules/opencv4nodejs/build/Release/opencv4nodejs'

Follow these steps and you should be able to install and work with this library. I've spent several hours trying to solve the issue and I think I've found something that works:

  1. Install OpenCV:
  • brew install opencv@4
  • brew link --force opencv@4
  1. Inside your repository:
  • Install your node modules but avoid installing opencv4nodejs via npm i.
  • Use a specific node version with nvm, node v14.18.1 or v14.17.0 will do.
  • Run export CXXFLAGS="-std=c++14 -Wno-c++11-narrowing" in the root of your project.
  • Run npm install opencv4nodejs

This process should actually trigger the build in opencv4nodejs and now the module can be used without issues.

i still cannot solve the problem with so many build error

I have the same issue on windows

I have the same issue on windows

This is supposed to fix macOS

Hi,
Great news for those people that do not want to build their OpenCV:
I published @u4/opencv4nodejs V 6.2.4 today,

This version autodetects the common setup path for Brew on Mac, Chocolatey on Windows, and Apt on Linux.

  • Windows:

choco install opencv

  • Mac:

brew install opencv

  • debian:

apt -y install libopencv-contrib-dev libopencv-dev

just define environment variable: OPENCV4NODEJS_DISABLE_AUTOBUILD=1

And your prebuild OpenCV will be used.

You may need to call:
npx build-opencv rebuild
or
npx build-opencv --nobuild rebuild (if you do not define OPENCV4NODEJS_DISABLE_AUTOBUILD variable)