Cannot find module '/Users/mac/Desktop/opencv4nodejs/build/Release/opencv4nodejs'
Error Message
After install opencv4nodejs when try run node faceDetection.js get this erorr
Cannot find module '/Users/mac/Desktop/opencv4nodejs/build/Release/opencv4nodejs'
/Users/mac/Desktop/imgg/node_modules/opencv4nodejs/lib/cv.js:47
throw err
^
Error: Cannot find module '/Users/mac/Desktop/imgg/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
at Function.Module._resolveFilename (module.js:513:15)
at Function.Module._load (module.js:463:25)
at Module.require (module.js:556:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/mac/Desktop/imgg/node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (module.js:612:30)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
Auto Build - Full Error Log
Manual Build - Environment Information
OpenCV version 4
OS: MacOSX catalina
const cv = require('opencv4nodejs')
I have the same problem.
WARNING in ./node_modules/opencv4nodejs/lib/cv.js 40:7-27
Critical dependency: the request of a dependency is an expression
@ ./node_modules/opencv4nodejs/lib/opencv4nodejs.js
@ ./src/app.js
@ ./src/index.js
WARNING in ./node_modules/opencv4nodejs/lib/cv.js 58:7-27
Critical dependency: the request of a dependency is an expression
@ ./node_modules/opencv4nodejs/lib/opencv4nodejs.js
@ ./src/app.js
@ ./src/index.js
ERROR in ./node_modules/opencv4nodejs/lib/opencv4nodejs.js
Module not found: Error: Can't resolve '../build/Release/opencv4nodejs.node' in '/App/node_modules/opencv4nodejs/lib'
@ ./node_modules/opencv4nodejs/lib/opencv4nodejs.js 11:29-75
@ ./src/app.js
@ ./src/index.js
ERROR in ./node_modules/opencv-build/build/utils.js
Module not found: Error: Can't resolve 'child_process' in '/App/node_modules/opencv-build/build'
@ ./node_modules/opencv-build/build/utils.js 39:20-44
@ ./node_modules/opencv-build/build/index.js
@ ./node_modules/opencv4nodejs/lib/cv.js
@ ./node_modules/opencv4nodejs/lib/opencv4nodejs.js
@ ./src/app.js
Same issue. Reinstalling opencv manually doesn't do anything.
Error: Cannot find module './node_modules/opencv4nodejs/build/Release/opencv4nodejs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (./node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Oddly enough,
const cv = require("./node_modules/opencv4nodejs/lib/opencv4nodejs.js")
gives the same exact error message
Same issue here, has anyone found a fix for this error?
./node_modules/opencv4nodejs/lib/cv.js:47
throw err
^
Error: Cannot find module './node_modules/opencv4nodejs/build/Release/opencv4nodejs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15)
at Function.Module._load (internal/modules/cjs/loader.js:580:25)
at Module.require (internal/modules/cjs/loader.js:711:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (./node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (internal/modules/cjs/loader.js:805:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
Has anyone found a fix for this error?
We encountered this error, which seemed to originate from a faulty build of opencv4nodejs, which passed with warnings, but didn't actually build the necessary files. Reinstalling xcode-select (command-line developer tools) and re-running the installation process solved this for us.
https://medium.com/flawless-app-stories/gyp-no-xcode-or-clt-version-detected-macos-catalina-anansewaa-38b536389e8d
Workaround - Add this script to your npm scripts:
"postinstall": "if [ ! -f node_modules/opencv4nodejs/build/Release/opencv4nodejs.node ]; then cd node_modules/opencv4nodejs/build; make; fi"
@robingenz What if my build folder doesn't exist