Mac M1笔记本,安装OpenCV4nodejs不成功

安装步骤如下:

  1. brew update
  2. brew install opencv@4
  3. brew link --force opencv@4
  4. export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
    export OPENCV_LIB_DIR=/opt/homebrew/Cellar/opencv/4.5.4_3/lib
    export OPENCV_BIN_DIR=/opt/homebrew/Cellar/opencv/4.5.4_3/bin
    export OPENCV_INCLUDE_DIR=/opt/homebrew/Cellar/opencv/4.5.4_3/include/opencv4
  5. npm install --save opencv4nodejs
    执行以上步骤后报错如下:
    npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (ReDos Vulnerability Regression Visibility Notice · Issue #797 · debug-js/debug · GitHub)
    npm WARN deprecated mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
    npm ERR! code 1
    npm ERR! path /Users/zhengxiangyu/.nvm/versions/node/v17.5.0/lib/node_modules/opencv4nodejs/node_modules/opencv-build/node_modules/opencv4nodejs
    npm ERR! command failed
    npm ERR! command sh -c node ./install/install.js
    npm ERR! info the following opencv4nodejs environment variables are set in the package.json:
    npm ERR! info opencvIncludeDir: /opt/homebrew/Cellar/opencv/4.5.4_4/include/opencv4
    npm ERR! info opencvLibDir: /opt/homebrew/Cellar/opencv/4.5.4_4/lib
    npm ERR! info opencvBinDir: /opt/homebrew/Cellar/opencv/4.5.4_4/bin
    npm ERR! info install using lib dir: /Users/zhengxiangyu/.nvm/versions/node/v17.5.0/lib/node_modules/opencv4nodejs/node_modules/opencv-build/node_modules/opencv-build/opencv/build/lib
    npm ERR! /Users/zhengxiangyu/.nvm/versions/node/v17.5.0/lib/node_modules/opencv4nodejs/node_modules/opencv-build/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: /Users/zhengxiangyu/.nvm/versions/node/v17.5.0/lib/node_modules/opencv4nodejs/node_modules/opencv-build/node_modules/opencv-build/opencv/build/lib
    npm ERR! at Object. (/Users/zhengxiangyu/.nvm/versions/node/v17.5.0/lib/node_modules/opencv4nodejs/node_modules/opencv-build/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:1151: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:77:12)
    npm ERR! at node:internal/main/run_main_module:17:47
    npm ERR!
    npm ERR! Node.js v17.5.0

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/zhengxiangyu/.npm/_logs/2022-02-14T14_26_28_338Z-debug-0.log

求教大神指点

https://github.com/justadudewhohacks/opencv4nodejs/issues/775#issuecomment-804347861

试试这个解决方案

!!新的解决方案在4楼哈:point_down::point_down:

试过,不好使

新的解决方案重开一帖进行描述

关闭