'Cannot find module '../build/Release/opencv4nodejs

I am new to OpenCV and node js, trying to learn OpenCV in node js.

I came across opencv4nodejs which I found best for learning.

I have followed all steps to install OpenCV and setting environment variables for OpenCV and done npm install opencv4nodejs also. able to run Quick start code given but when I try to run example machineLearningOCR.js from examples folder I get error Error: Cannot find module '../build/Release/opencv4nodejs'

I run command node machineLearningOCR.js from cmd but getting error mentioned above on line const cv = require('../');

How to run examples given in opencv4nodejs?



Solution 1:[1]

If you cloned the repository and want to use the examples directly from the examples folder then you have to npm install in the root directory first to build the module.

Optionally you can npm install opencv4nodejs in any project directory, copy the examples into that directory and replace const cv = require('../'); with const cv = require('opencv4nodejs');.

You can also directly submit an issue here: https://github.com/justadudewhohacks/opencv4nodejs/issues

Solution 2:[2]

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 14.16.0

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

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 justadudewhohacks
Solution 2 eventsequor