Description
Hey there,
I'm trying to get a nestjs service of mine production ready and I'm struggling with the deployment process when using docker. Even with the official docker image I can't get the application to run.
I have provided an example project that anyone can clone and try for themself https://github.com/rstoye/opencv-troubleshoot-2. Just follow the readme of that repo to recreate the error.
The issue is that after installing the npm packages, linking the globally installed @u4/opencv4nodejs
module and building the project, I get the following error upon running the build:
Error: Cannot find module '/usr/local/lib/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:
- /usr/local/lib/node_modules/@u4/opencv4nodejs/lib/cvloader.js
- /usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js
- /usr/src/app/app.service.js
- /usr/src/app/app.controller.js
- /usr/src/app/app.module.js
- /usr/src/app/main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at getOpenCV (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/cvloader.js:55:23)
at loadOpenCV (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:9:43)
at Object.<anonymous> (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:24:12)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/cvloader.js',
'/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js',
'/usr/src/app/app.service.js',
'/usr/src/app/app.controller.js',
'/usr/src/app/app.module.js',
'/usr/src/app/main.js'
]
}
The error makes sense in that there certainly is no build
folder under /usr/local/lib/node_modules/@u4/opencv4nodejs/
. Why the path for the module wants to access a build/Release
directory is beyond me. All I do in my source code is importing like so import * as openCv from '@u4/opencv4nodejs';
Any help on this matter would be greatly appreciated.