justadudewhohacks / opencv4nodejs

Nodejs bindings to OpenCV 3 and OpenCV 4
MIT License
4.94k stars 820 forks source link

Unable to install: `library dir does not exist` #837

Open gamingredpandas opened 2 years ago

gamingredpandas commented 2 years ago

Description

I am trying to use opencv4nodejs to capture my webcam, but I am not able to install it. I tried a lot of other things and other ways to install opencv4nodejs, but none were successful, so I will just post the result of an auto build.

Error Message

Error: library dir does not exist: D:/projects/webcam/node_modules/opencv-build/opencv/build/lib/Release

Auto Build - Full Error Log

npm install --save opencv4nodejs npm WARN cleanup Failed to remove some directories [ npm WARN cleanup [ npm WARN cleanup 'D:\projects\webcam\node_modules', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'D:\projects\webcam\node_modules\opencv-build'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'D:\projects\webcam\node_modules\opencv-build' npm WARN cleanup } npm WARN cleanup ] npm WARN cleanup ] npm ERR! code 1 npm ERR! path D:\projects\webcam\node_modules\opencv4nodejs npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./install/install.js npm ERR! info install using lib dir: D:/projects/webcam/node_modules/opencv-build/opencv/build/lib/Release npm ERR! D:\projects\webcam\node_modules\opencv4nodejs\install\install.js:37 npm ERR! throw new Error('library dir does not exist: ' + libDir) npm ERR! ^ npm ERR! npm ERR! Error: library dir does not exist: D:/projects/webcam/node_modules/opencv-build/opencv/build/lib/Release npm ERR! at Object. (D:\projects\webcam\node_modules\opencv4nodejs\install\install.js:37:9) npm ERR! at Module._compile (node:internal/modules/cjs/loader:1097:14) npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10) npm ERR! at Module.load (node:internal/modules/cjs/loader:975:32) npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:822:12) npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) npm ERR! at node:internal/main/run_main_module:17:47 npm ERR! npm ERR! Node.js v17.3.0

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\\AppData\Local\npm-cache_logs\2022-01-03T14_55_06_355Z-debug-0.log

OpenCV version : 5.6.0

With OpenCV-contrib? (extra modules): no

OS: Windows 10

liudonghua123 commented 2 years ago

I have the same problems.

`npm i -g opencv4nodejs --verbose` ```shell C:\Users\Liu.D.H>npm i -g opencv4nodejs --verbose npm verb cli [ npm verb cli 'C:\\Program Files\\nodejs\\node.exe', npm verb cli 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js', npm verb cli 'i', npm verb cli '-g', npm verb cli 'opencv4nodejs', npm verb cli '--verbose' npm verb cli ] npm info using npm@8.3.0 npm info using node@v16.13.1 npm timing npm:load:whichnode Completed in 1ms npm timing config:load:defaults Completed in 1ms npm timing config:load:file:C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 2ms npm timing config:load:builtin Completed in 3ms npm timing config:load:cli Completed in 2ms npm timing config:load:env Completed in 1ms npm timing config:load:project Completed in 1ms npm timing config:load:file:C:\Users\Liu.D.H\.npmrc Completed in 2ms npm timing config:load:user Completed in 3ms npm timing config:load:file:C:\Users\Liu.D.H\AppData\Roaming\npm\etc\npmrc Completed in 0ms npm timing config:load:global Completed in 0ms npm timing config:load:validate Completed in 2ms npm timing config:load:credentials Completed in 0ms npm timing config:load:setEnvs Completed in 1ms npm timing config:load Completed in 15ms npm timing npm:load:configload Completed in 15ms npm timing npm:load:setTitle Completed in 1ms npm timing config:load:flatten Completed in 3ms npm timing npm:load:display Completed in 16ms npm verb logfile C:\Users\Liu.D.H\AppData\Local\npm-cache\_logs\2022-01-04T08_06_52_850Z-debug-0.log npm timing npm:load:logFile Completed in 9ms npm timing npm:load:timers Completed in 0ms npm timing npm:load:configScope Completed in 0ms npm timing npm:load Completed in 45ms npm timing arborist:ctor Completed in 1ms npm timing idealTree:init Completed in 5ms npm timing idealTree:userRequests Completed in 2ms npm http fetch GET 200 https://registry.npmjs.org/opencv4nodejs 2048ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/nan 281ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/npmlog 880ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@types%2fnode 906ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/opencv-build 1010ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/native-node-utils 2528ms (cache revalidated) npm timing idealTree:#root Completed in 4603ms npm http fetch GET 200 https://registry.npmjs.org/console-control-strings 238ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/gauge 242ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/are-we-there-yet 250ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/set-blocking 1280ms (cache revalidated) npm timing idealTree:node_modules/opencv4nodejs Completed in 1316ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/@types/node Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/nan Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/native-node-utils Completed in 0ms npm http fetch GET 200 https://registry.npmjs.org/delegates 259ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/readable-stream 278ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/has-unicode 282ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/object-assign 763ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/signal-exit 798ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/strip-ansi 889ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/string-width 898ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/aproba 1145ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/wide-align 1303ms (cache revalidated) npm timing idealTree:node_modules/opencv4nodejs/node_modules/npmlog Completed in 1339ms npm http fetch GET 200 https://registry.npmjs.org/inherits 250ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/isarray 252ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/string_decoder 252ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/core-util-is 258ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/safe-buffer 260ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/process-nextick-args 267ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/util-deprecate 265ms (cache revalidated) npm timing idealTree:node_modules/opencv4nodejs/node_modules/are-we-there-yet Completed in 278ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/console-control-strings Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/delegates Completed in 0ms npm http fetch GET 200 https://registry.npmjs.org/ansi-regex 236ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/is-fullwidth-code-point 241ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/code-point-at 245ms (cache revalidated) npm timing idealTree:node_modules/opencv4nodejs/node_modules/gauge Completed in 258ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/aproba Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/has-unicode Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/object-assign Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/opencv-build Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/readable-stream Completed in 8ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/core-util-is Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/inherits Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/isarray Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/process-nextick-args Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/safe-buffer Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/set-blocking Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/signal-exit Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/string_decoder Completed in 0ms npm http fetch GET 200 https://registry.npmjs.org/number-is-nan 228ms (cache revalidated) npm timing idealTree:node_modules/opencv4nodejs/node_modules/string-width Completed in 241ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/code-point-at Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/is-fullwidth-code-point Completed in 6ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/number-is-nan Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/strip-ansi Completed in 6ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/ansi-regex Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/util-deprecate Completed in 0ms npm timing idealTree:node_modules/opencv4nodejs/node_modules/wide-align Completed in 1ms npm timing idealTree:buildDeps Completed in 8088ms npm timing idealTree:fixDepFlags Completed in 2ms npm timing idealTree Completed in 8103ms npm timing reify:loadTrees Completed in 8123ms npm timing reify:diffTrees Completed in 2ms npm timing reify:retireShallow Completed in 5ms npm timing reify:createSparse Completed in 15ms npm timing reify:loadBundles Completed in 0ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/code-point-at Completed in 193ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/number-is-nan Completed in 194ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/process-nextick-args Completed in 194ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/ansi-regex Completed in 195ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/is-fullwidth-code-point Completed in 195ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/has-unicode Completed in 196ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/wide-align Completed in 196ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/string-width Completed in 197ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/strip-ansi Completed in 197ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/object-assign Completed in 198ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/aproba Completed in 200ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/core-util-is Completed in 202ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/inherits Completed in 207ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/signal-exit Completed in 208ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/set-blocking Completed in 209ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/console-control-strings Completed in 209ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/safe-buffer Completed in 214ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/string_decoder Completed in 215ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/npmlog Completed in 214ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/util-deprecate Completed in 219ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/isarray Completed in 227ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/delegates Completed in 229ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/are-we-there-yet Completed in 235ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/native-node-utils Completed in 267ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/gauge Completed in 271ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/readable-stream Completed in 285ms npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 311ms npm timing auditReport:getReport Completed in 315ms npm timing auditReport:init Completed in 0ms npm timing reify:audit Completed in 316ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/opencv-build Completed in 318ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/nan Completed in 343ms npm timing reifyNode:node_modules/opencv4nodejs/node_modules/@types/node Completed in 400ms npm timing reifyNode:node_modules/opencv4nodejs Completed in 757ms npm timing reify:unpack Completed in 759ms npm timing reify:unretire Completed in 1ms npm timing build:queue Completed in 3ms npm info run opencv4nodejs@5.6.0 install node_modules/opencv4nodejs node ./install/install.js npm info run opencv-build@0.1.9 install node_modules/opencv4nodejs/node_modules/opencv-build node ./install.js npm info run opencv4nodejs@5.6.0 install { code: 1, signal: null } npm WARN cleanup Failed to remove some directories [ npm WARN cleanup [ npm WARN cleanup 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs\\node_modules\\opencv-build' npm WARN cleanup } npm WARN cleanup ], npm WARN cleanup [ npm WARN cleanup 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs\\node_modules\\opencv-build' npm WARN cleanup } npm WARN cleanup ] npm WARN cleanup ] npm timing reify:rollback:createSparse Completed in 13198ms npm timing reify:rollback:retireShallow Completed in 344ms npm timing command:i Completed in 22970ms npm verb stack Error: command failed npm verb stack at ChildProcess. (C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27) npm verb stack at ChildProcess.emit (node:events:390:28) npm verb stack at maybeClose (node:internal/child_process:1064:16) npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) npm verb pkgid opencv4nodejs@5.6.0 npm verb cwd C:\Users\Liu.D.H npm verb Windows_NT 10.0.22000 npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "-g" "opencv4nodejs" "--verbose" npm verb node v16.13.1 npm verb npm v8.3.0 npm ERR! code 1 npm ERR! path C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\opencv4nodejs npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./install/install.js npm ERR! info install using lib dir: C:/Users/Liu.D.H/AppData/Roaming/npm/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib/Release npm ERR! C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\opencv4nodejs\install\install.js:37 npm ERR! throw new Error('library dir does not exist: ' + libDir) npm ERR! ^ npm ERR! npm ERR! Error: library dir does not exist: C:/Users/Liu.D.H/AppData/Roaming/npm/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib/Release npm ERR! at Object. (C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\opencv4nodejs\install\install.js:37:9) npm ERR! at Module._compile (node:internal/modules/cjs/loader:1101:14) npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) npm ERR! at Module.load (node:internal/modules/cjs/loader:981:32) npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:822:12) npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) npm ERR! at node:internal/main/run_main_module:17:47 npm verb exit 1 npm timing npm Completed in 23338ms npm verb unfinished npm timer reify 1641283613203 npm verb unfinished npm timer reify:build 1641283622128 npm verb unfinished npm timer build 1641283622128 npm verb unfinished npm timer build:deps 1641283622129 npm verb unfinished npm timer build:run:install 1641283622132 npm verb unfinished npm timer build:run:install:node_modules/opencv4nodejs 1641283622133 npm verb unfinished npm timer build:run:install:node_modules/opencv4nodejs/node_modules/opencv-build 1641283622141 npm verb code 1 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Liu.D.H\AppData\Local\npm-cache\_logs\2022-01-04T08_06_52_850Z-debug-0.log C:\Users\Liu.D.H> ```
SuperSchek commented 2 years ago

Experiencing the same issue on MacOS using node version 16.13.1.

UrielCh commented 2 years ago

Please try that : in am admin power shell

choco install cmake -y

in you user cmd / powershell

cd D:\projects\webcam
npm i -g node-gyp
npm i @u4/opencv4nodejs
echo build nodejs
node .\node_modules\.bin\build-opencv --help
node .\node_modules\.bin\build-opencv --version 4.5.4 build

The errors messages of this version are way cleaner, and the build should works fine with nodeJS 16

PS: do not use 4.5.5 on MacOS. PS: the original version do not work with Visual Studio 2019.

moontai0724 commented 2 years ago

In my situation, the root cause is that it cannot auto build (or even install) the opencv-build package.

When I try to install opencv-build by executing npm i opencv-build, it stucked on reify:... Completed in XXXms, then I found this thread.

After downgrade npm by npm i -g npm@6, then try again, everything works like a charm.

jazozaya commented 2 years ago

I was having issues with this as well. Downgrading to Node 14 worked for me.

tekisrinivas20 commented 2 years ago

In my situation, the root cause is that it cannot auto build (or even install) the opencv-build package.

When I try to install opencv-build by executing npm i opencv-build, it stucked on reify:... Completed in XXXms, then I found this thread.

After downgrade npm by npm i -g npm@6, then try again, everything works like a charm.

Thanks for the information, I also faced the same issue, and it worked after downgrading the npm version to 6

UrielCh commented 2 years ago

Hi, Great news for those people that do not want to build their OpenCV: I published @u4/opencv4nodejs V 6.2.4 today,

This version autodetects the common setup path for Brew on Mac, Chocolatey on Windows, and Apt on Linux.

just define environment variable: OPENCV4NODEJS_DISABLE_AUTOBUILD=1

And your prebuild OpenCV will be used.

You may need to call: npx build-opencv rebuild or npx build-opencv --nobuild rebuild (if you do not define OPENCV4NODEJS_DISABLE_AUTOBUILD variable)

dids-reyes commented 2 months ago

npm i -g npm@6

tried this and i got pass the error library dir does not exist

but im getting this error now

[ 50%] Built target libprotobuf
make: *** [all] Error 2

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build@0.1.9 install: `node ./install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build@0.1.9 install script.