Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing to install opencv4nodejs on Mac (Apple M1) throws path not found error

INBASDLP13987:~ kanopi$ sudo npm install -g opencv4nodejs Password: npm ERR! code 1 npm ERR! path /opt/homebrew/lib/node_modules/opencv4nodejs npm ERR! command failed npm ERR! command sh -c node ./install/install.js npm ERR! info install using lib dir: /opt/homebrew/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib npm ERR! /opt/homebrew/lib/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: /opt/homebrew/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib npm ERR! at Object. (/opt/homebrew/lib/node_modules/opencv4nodejs/install/install.js:37:9) npm ERR! at Module._compile (node:internal/modules/cjs/loader:1092:14) npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10) npm ERR! at Module.load (node:internal/modules/cjs/loader:972:32) npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:813:14) npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) npm ERR! at node:internal/main/run_main_module:17:47

npm ERR! A complete log of this run can be found in: npm ERR! /Users/kanopi/.npm/_logs/2021-03-25T01_15_39_828Z-debug.log

Please help in resolving this issue...

Also tried the below:

npm i opencv4nodejs npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]: Deprecated due to CVE-2021-21366 resolved in 0.5.0 npm WARN deprecated [email protected]: Deprecated due to CVE-2021-21366 resolved in 0.5.0 npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code 1 npm ERR! path /opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent/node_modules/opencv4nodejs npm ERR! command failed npm ERR! command sh -c node ./install/install.js npm ERR! info install using lib dir: /opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent/node_modules/opencv-build/opencv/build/lib npm ERR! /opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent/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: /opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent/node_modules/opencv-build/opencv/build/lib npm ERR! at Object. (/opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent/node_modules/opencv4nodejs/install/install.js:37:9) npm ERR! at Module._compile (node:internal/modules/cjs/loader:1092:14) npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10) npm ERR! at Module.load (node:internal/modules/cjs/loader:972:32) npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:813:14) npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) npm ERR! at node:internal/main/run_main_module:17:47

npm ERR! A complete log of this run can be found in: npm ERR! /Users/kanopi/.npm/_logs/2021-03-25T14_06_03_819Z-debug.log

like image 940
Device Automation Tech Mahindr Avatar asked Mar 25 '21 01:03

Device Automation Tech Mahindr


Video Answer


1 Answers

It worked when specifically installing opencv-build before-hand, but make sure neither opencv-build nor opencv4nodejs are actually defined in package.json dependencies,

So what I did is install them via postinstall as such:

"scripts": {
    "postinstall": "npm i opencv-build && npm i opencv4nodejs",

For this, I first had to install cmake in my case.

brew install cmake

BTW: It also took quite a while to install opencv-build - minutes of very intensive processing - according to the extra heat and sound emitted, and I thought it was stuck at first.

With this approach we can use opencv4nodejs but it's not listed as a dependency.

like image 137
Ovidiu Dolha Avatar answered Oct 20 '22 03:10

Ovidiu Dolha