Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module node_modules/opencv4nodejs/build/Release/opencv4nodejs #853

Open
dengbupapapa opened this issue Jun 27, 2022 · 12 comments

Comments

@dengbupapapa
Copy link

//example.js
const opencv4nodejs = require("opencv4nodejs")
+ [email protected]
added 2 packages from 1 contributor and audited 30 packages in 43.127s
found 0 vulnerabilities

dengshiwei@dengshiweideMacBook-Pro analysis-image % node example.js
/Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/cv.js:47
    throw err
    ^

Error: Cannot find module '/Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:
- /Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/cv.js
- /Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/opencv4nodejs.js
- /Users/dengshiwei/Desktop/work/analysis-image/example.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/cv.js:40:8)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/cv.js',
    '/Users/dengshiwei/Desktop/work/analysis-image/node_modules/opencv4nodejs/lib/opencv4nodejs.js',
    '/Users/dengshiwei/Desktop/work/analysis-image/example.js'
  ]
}
@yaoyuanrong
Copy link

same question

@yaoyuanrong
Copy link

Did you solve it?

@dengbupapapa
Copy link
Author

Did you solve it?
no

@EdoTrotta
Copy link

#852

This should solve the issue.

@fendiflexin
Copy link

fendiflexin commented Jun 29, 2022

The problem that I was facing had something to do with the opencv4nodejs autobuild.

I was able to solve this by manually building opencv4nodejs.

"opencv4nodejs": { "disableAutoBuild": "1", "OPENCV_INCLUDE_DIR": "C:\\opencv\\build\\include", "OPENCV_LIB_DIR": "C:\\opencv\\build\\x64\\vc15\\lib", "OPENCV_BIN_DIR": "C:\\opencv\\build\\x64\\vc14\\bin" },

"scripts": { "install": "build-opencv --incDir C:\\opencv\\build\\include --libDir C:\\opencv\\build\\x64\\vc15\\lib --binDir C:\\opencv\\build\\x64\\vc15\\bin --nobuild rebuild" }

Replace each path in the lines above with your own respective path to opencv and add them to your package.json file,
Then run, npm run install to build opencv4nodejs. After a successful build you can then run your application.

@ToWelie89
Copy link

When I try to do that I just get

'build-opencv' is not recognized as an internal or external command

@UrielCh
Copy link
Contributor

UrielCh commented Aug 13, 2022

try using npx
npx build-opencv --help

and use @u4/opencv4nodejs

@ToWelie89
Copy link

try using npx npx build-opencv --help

and use @u4/opencv4nodejs

Thanks. I did switch over to @u4/opencv4nodejs. It does work better, I still have a problem when it comes to getting it to work in Electron though. I submitted an issue about it to @u4/opencv4nodejs

@UrielCh
Copy link
Contributor

UrielCh commented Aug 13, 2022

I do not use electron, please refer to the u4 election sample.

@Yupe245
Copy link

Yupe245 commented Jun 25, 2023

I tried and it gives this err;
I also tried with sudo and its still same

info config found opencv4nodejs section in /Users/yscnpkr/Desktop/projeler/FaceRecognition/package.json
info envAutodetect autodetect 0 changes
info applyEnvsFromPackageJson the following opencv4nodejs environment variables are set in the package.json:
info applyEnvsFromPackageJson disableAutoBuild: 1
info applyEnvsFromPackageJson opencvIncludeDir: /opt/homebrew/Cellar/opencv/4.7.0_7/include
info applyEnvsFromPackageJson opencvLibDir: /opt/homebrew/Cellar/opencv/4.7.0_7/lib
info applyEnvsFromPackageJson opencvBinDir: /opt/homebrew/Cellar/opencv/4.7.0_7/bin
info install Using openCV 0.0.0
info install Using lib dir: /opt/homebrew/Cellar/opencv/4.7.0_7/lib
info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set skipping auto build...
info install writing auto-build file into directory: /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv-build/dist/opencv-0.0.0-8b1ea/auto-build.json
info install Cretate link /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv-build/dist/latest to /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv-build/dist/opencv-0.0.0-8b1ea
info install
info install Found the following libs:
info install core: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_core.4.7.0.dylib
info install imgproc: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_imgproc.4.7.0.dylib
info install imgcodecs: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_imgcodecs.4.7.0.dylib
info install videoio: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_videoio.4.7.0.dylib
info install highgui: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_highgui.4.7.0.dylib
info install video: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_video.4.7.0.dylib
info install calib3d: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_calib3d.4.7.0.dylib
info install features2d: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_features2d.4.7.0.dylib
info install objdetect: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_objdetect.4.7.0.dylib
info install dnn: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_dnn.4.7.0.dylib
info install ml: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_ml.4.7.0.dylib
info install flann: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_flann.4.7.0.dylib
info install photo: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_photo.4.7.0.dylib
info install gapi: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_gapi.4.7.0.dylib
info install face: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_face.4.7.0.dylib
info install img_hash: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_img_hash.4.7.0.dylib
info install text: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_text.4.7.0.dylib
info install tracking: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_tracking.4.7.0.dylib
info install videostab: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_videostab.4.7.0.dylib
info install xfeatures2d: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_xfeatures2d.4.7.0.dylib
info install ximgproc: /opt/homebrew/Cellar/opencv/4.7.0_7/lib/libopencv_ximgproc.4.7.0.dylib
info defines
info defines Setting the following defines:
info defines OPENCV4NODEJS_FOUND_LIBRARY_CORE OPENCV4NODEJS_FOUND_LIBRARY_IMGPROC OPENCV4NODEJS_FOUND_LIBRARY_IMGCODECS
info defines OPENCV4NODEJS_FOUND_LIBRARY_VIDEOIO OPENCV4NODEJS_FOUND_LIBRARY_HIGHGUI OPENCV4NODEJS_FOUND_LIBRARY_VIDEO
info defines OPENCV4NODEJS_FOUND_LIBRARY_CALIB3D OPENCV4NODEJS_FOUND_LIBRARY_FEATURES2D OPENCV4NODEJS_FOUND_LIBRARY_OBJDETECT
info defines OPENCV4NODEJS_FOUND_LIBRARY_DNN OPENCV4NODEJS_FOUND_LIBRARY_ML OPENCV4NODEJS_FOUND_LIBRARY_FLANN
info defines OPENCV4NODEJS_FOUND_LIBRARY_PHOTO OPENCV4NODEJS_FOUND_LIBRARY_GAPI OPENCV4NODEJS_FOUND_LIBRARY_FACE
info defines OPENCV4NODEJS_FOUND_LIBRARY_IMG_HASH OPENCV4NODEJS_FOUND_LIBRARY_TEXT OPENCV4NODEJS_FOUND_LIBRARY_TRACKING
info defines OPENCV4NODEJS_FOUND_LIBRARY_VIDEOSTAB OPENCV4NODEJS_FOUND_LIBRARY_XFEATURES2D OPENCV4NODEJS_FOUND_LIBRARY_XIMGPROC
info install
info install Setting the following includes:
info includes /opt/homebrew/Cellar/opencv/4.7.0_7/include
info libs
info libs Setting lib from -L/opt/homebrew/Cellar/opencv/4.7.0_7 : lib, -lopencv_core, -lopencv_imgproc, -lopencv_imgcodecs, -lopencv_videoio, -lopencv_highgui, -lopencv_video, -lopencv_calib3d, -lopencv_features2d, -lopencv_objdetect, -lopencv_dnn, -lopencv_ml, -lopencv_flann, -lopencv_photo, -lopencv_gapi, -lopencv_face, -lopencv_img_hash, -lopencv_text, -lopencv_tracking, -lopencv_videostab, -lopencv_xfeatures2d, -lopencv_ximgproc, lib
info install Spawning in directory:/Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv4nodejs node-gyp process: node-gyp rebuild --jobs max --release
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, unlink 'build/Makefile'
gyp ERR! System Darwin 22.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/.bin/node-gyp" "rebuild" "--jobs" "max" "--release"
gyp ERR! cwd /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv4nodejs
gyp ERR! node -v v18.14.2
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
error: Error: Command failed: node-gyp rebuild --jobs max --release
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, unlink 'build/Makefile'
gyp ERR! System Darwin 22.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/.bin/node-gyp" "rebuild" "--jobs" "max" "--release"
gyp ERR! cwd /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv4nodejs
gyp ERR! node -v v18.14.2
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) {

code: 1,
killed: false,
signal: null,
cmd: 'node-gyp rebuild --jobs max --release '
}
ERR! install node-gyp failed and return Error Command failed: node-gyp rebuild --jobs max --release
ERR! install gyp info it worked if it ends with ok
ERR! install gyp info using [email protected]
ERR! install gyp info using [email protected] | darwin | arm64
ERR! install gyp ERR! clean error
ERR! install gyp ERR! stack Error: EACCES: permission denied, unlink 'build/Makefile'
ERR! install gyp ERR! System Darwin 22.5.0
ERR! install gyp ERR! command "/usr/local/bin/node" "/Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/.bin/node-gyp" "rebuild" "--jobs" "max" "--release"
ERR! install gyp ERR! cwd /Users/yscnpkr/Desktop/projeler/FaceRecognition/node_modules/@u4/opencv4nodejs
ERR! install gyp ERR! node -v v18.14.2
ERR! install gyp ERR! node-gyp -v v9.4.0
ERR! install gyp ERR! not ok
ERR! install return code: 1

@INDERJEET0202
Copy link

try using npx npx build-opencv --help

and use @u4/opencv4nodejs

i am facing very much issue in build, error saying that build failed. How can I build? (Macos)

@zjx-git
Copy link

zjx-git commented Oct 11, 2024

try using npx npx build-opencv --help
and use @u4/opencv4nodejs

Thanks. I did switch over to @u4/opencv4nodejs. It does work better, I still have a problem when it comes to getting it to work in Electron though. I submitted an issue about it to @u4/opencv4nodejs

hello, did you solve it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants