Opencv4nodejs: The specified module could not be found.

Created on 13 Dec 2017  路  7Comments  路  Source: justadudewhohacks/opencv4nodejs

I moved an NW.js project that uses opencv4nodejs from macOS to Windows. In doing so, I had to recompile the module. I did that with: nw-gyp rebuild --target=0.27.1 The compilation process completed successfully.

However, when I start my project, I get this error in the console:

Uncaught Error: The specified module could not be found.
\\?\C:\Users\jpcote\app\package.nw\node_modules\opencv4nodejs\build\Release\opencv4nodejs.node
    at Object.Module._extensions..node (module.js:713:18)
    at Module.load (module.js:585:32)
    at tryModuleLoad (module.js:528:12)
    at Function.Module._load (module.js:520:3)
    at Module.require (module.js:610:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\jpcote\app\package.nw\node_modules\opencv4nodejs\lib\opencv4nodejs.js:7:8)
    at Module._compile (module.js:666:30)
    at Object.Module._extensions..js (module.js:683:10)
    at Module.load (module.js:585:32)

The odd thing is that the "missing" file (opencv4nodejs.node) is definitely there. Ideas?

Most helpful comment

Yes, I'm a total newbie with OpenCV. But, I guess you already figured that out! ;-) As you said, a lot of people using opencv4nodejs will probably never have touched OpenCV.

I followed your instructions and now it works. Just for future reference, here are my settings:

C:\Users\jpcote>echo %OPENCV_BIN_DIR%
C:\opencv\build\x64\vc14\bin

C:\Users\jpcote>echo %OPENCV_DIR%
C:\opencv\build

C:\Users\jpcote>echo %OPENCV_INCLUDE_DIR%
C:\opencv\build\include

C:\Users\jpcote>echo %OPENCV_LIB_DIR%
C:\opencv\build\x64\vc14\lib

Obviously, I also added %OPENCV_BIN_DIR% to my Path system variable. My project now works on macOS, Windows and GNU/Linux. Yeah!

Thanks again!

All 7 comments

Hi, you are probably missing the OpenCV binaries in your system path.
Is the error thrown at:

module.js:597
  return process.dlopen(module, path._makeLong(filename));

?

Might be same issue as #50.

Hmm. This is what I have:

C:\Users\jpcote>echo %OPENCV_DIR%
C:\opencv\build

C:\Users\jpcote>echo %OPENCV_INCLUDE_DIR%
C:\opencv\build\include

C:\Users\jpcote>echo %OPENCV_LIB_DIR%
C:\opencv\build\x64\vc14\lib

Isn't that correct?

In order to use OpenCV on windows one has to add also the path to the binaries (opencv .dlls) manually to their system path.

The .dlls are probably located somewhere at \build\x64\vc14\bin. You can add an environment variable called OPENCV_BIN_DIR and append %OPENCV_BIN_DIR%; to your system path.

I should probably add this step in the setup section. Seems like a lot of users of this package haven't setup OpenCV on their systems before :D

Yes, I'm a total newbie with OpenCV. But, I guess you already figured that out! ;-) As you said, a lot of people using opencv4nodejs will probably never have touched OpenCV.

I followed your instructions and now it works. Just for future reference, here are my settings:

C:\Users\jpcote>echo %OPENCV_BIN_DIR%
C:\opencv\build\x64\vc14\bin

C:\Users\jpcote>echo %OPENCV_DIR%
C:\opencv\build

C:\Users\jpcote>echo %OPENCV_INCLUDE_DIR%
C:\opencv\build\include

C:\Users\jpcote>echo %OPENCV_LIB_DIR%
C:\opencv\build\x64\vc14\lib

Obviously, I also added %OPENCV_BIN_DIR% to my Path system variable. My project now works on macOS, Windows and GNU/Linux. Yeah!

Thanks again!

Great! Always nice to see people building stuff with this package =)

I'm working on an interactive art installation. It needs to be ready for February. It'll be awesome!

Sounds interesting! Feel free to share the result of your project or to reach out, in case you have more questions about the package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OluAgunloye picture OluAgunloye  路  3Comments

sinitsyn-alex picture sinitsyn-alex  路  4Comments

je3f0o picture je3f0o  路  6Comments

fildaniels picture fildaniels  路  5Comments

YaronHershkovitz picture YaronHershkovitz  路  6Comments