在 mac m1 bigSur 上 npm install opencv4nodejs 错误

问题描述

我一直在尝试使用 npm install opencv4nodejs 命令安装 opencv4nodejs 包。但不幸的是,下面正在被抛出。做了一些研究并做了一些调整,但所有这些都没有奏效。

错误如下:

manikanthvanka@Manikanths-MacBook-Pro react-file-upload-master % npm install opencv4nodejs
> opencv-build@0.1.9 install /Users/manikanthvanka/Downloads/react- 
file-upload-master/node_modules/opencv-build
> node ./install.js
info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set
info install skipping auto build...

> opencv4nodejs@5.6.0 install /Users/manikanthvanka/Downloads/react- 
file-upload-master/node_modules/opencv4nodejs
> node ./install/install.js

info install OPENCV_LIB_DIR is not set,looking for default lib dir
info install using lib dir: /usr/local/lib
/Users/manikanthvanka/Downloads/react-file-upload- 
master/node_modules/opencv4nodejs/install/install.js:45
throw new Error('no OpenCV libraries found in lib dir: ' + libDir)
 ^

 Error: no OpenCV libraries found in lib dir: /usr/local/lib
 at Object.<anonymous> (/Users/manikanthvanka/Downloads/react-file- 
 upload-master/node_modules/opencv4nodejs/install/install.js:45:9)
 at Module._compile (internal/modules/cjs/loader.js:1063:30)
 at Object.Module._extensions..js 
 (internal/modules/cjs/loader.js:1092:10)
 at Module.load (internal/modules/cjs/loader.js:928:32)
 at Function.Module._load (internal/modules/cjs/loader.js:769:14)
 at Function.executeUserEntryPoint [as runMain] 
 (internal/modules/run_main.js:72:12)
  at internal/main/run_main_module.js:17:47
  npm WARN @tinymce/tinymce-react@3.10.2 requires a peer of 
  react@^17.0.1 but none is installed. You must install peer 
  dependencies yourself.
  npm WARN @tinymce/tinymce-react@3.10.2 requires a peer of react- 
  dom@^17.0.1 but none is installed. You must install peer 
  dependencies yourself.
  npm WARN bootstrap@4.6.0 requires a peer of jquery@1.9.1 - 3 but 
  none is installed. You must install peer dependencies yourself.
  npm WARN bootstrap@4.6.0 requires a peer of popper.js@^1.16.1 but n. 
  one is installed. You must install peer dependencies yourself.
  npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 
  3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 
  3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none 
  is installed. You must install peer dependencies yourself.

   npm ERR! code ELIFECYCLE
   npm ERR! errno 1
   npm ERR! opencv4nodejs@5.6.0 install: `node ./install/install.js`
   npm ERR! Exit status 1
   npm ERR! 
   npm ERR! Failed at the opencv4nodejs@5.6.0 install script.
   npm ERR! This is probably not a problem with npm. There is likely 
   additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/manikanthvanka/.npm/_logs/2021-03- 
    07T11_03_42_873Z-debug.log
    manikanthvanka@Manikanths-MacBook-Pro react-file-upload-master % 

解决方法

试试这个

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins"> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <title>Document</title> </head> <body> <div class="container"> <div class="header"> <!--header open--> <div class="header-wrapper"> <div class="site-title"> <p> <span class="site-title-span">B</span>ee <span class="site-title-span">B</span>uzz </p> </div> <div class="nav"> <ul> <li><a href="#" class="active">HOME</a></li> <li><a href="#">SERVICES</a></li> <li><a href="#">CONTACT</a></li> <li><a href="#">ABOUT</a></li> </ul> </div> </div> </div> <!--header closed--> <!-- HERO SECTION --> <div class="hero"> <div class="hero-wrapper"> <div class="site-info"> <h1 class="site-info-heading"> <span style="color:#E47700;font-weight:bolder;">B</span>ee <span style="color:#E47700;font-weight:bolder;">B</span>uzz <span style="font-size:.5em;">TM</span> </h1> <p class="site-info-text"> We are providing pure forest bee honey and protecting our environment </p> <button class="site-info-btn"> Read more </button> </div> <div class="hero-beehive"> <svg id="hero-svg" width="300" height="300" viewBox="0 50 630 630" fill="none" xmlns="http://www.w3.org/2000/svg"> <symbol id="theBee" viewBox="0 0 78 49" > <g id="complete_bee"> <path id="bee head" d="M11.553 35.5047C16.3904 38.8245 21.8681 37.8364 24.0023 36.4532V15.1115C22.9352 14.4397 19.5917 13.499 14.7542 15.1115C9.9168 16.724 8.37329 20.5655 7.99604 21.7512C6.88944 25.2291 6.71554 32.1848 11.553 35.5047Z" fill="#FFE818" stroke="black" /> <circle id="bee eye" cx="15.532" cy="21.6908" r="2.96412" fill="#313131" /> <path id="bee trunk" d="M65.8034 15.1697C45.3154 7.5816 30.1154 12.008 23.9501 15.1697V36.6299C37.3242 43.649 56.6739 38.0527 64.1435 34.3772C78.0156 27.5513 77.7785 19.6049 65.8034 15.1697Z" fill="#FFE818" stroke="black" /> <path id="trunk lines" d="M32.961 12.087C30.4711 16.1577 26.9142 26.5519 32.3682 39.3569L35.8065 39.8312C29.8309 27.5004 34.2652 15.5649 36.7551 11.4942L32.961 12.087Z" fill="#4E4E4E" stroke="black" /> <path id="trunk lines_2" d="M42.9204 39.8312C36.9447 27.5005 41.2605 15.0907 43.7503 11.02L47.7815 11.1385C45.2917 15.2092 40.5017 27.1448 46.4773 39.4755L42.9204 39.8312Z" fill="#313131" stroke="black" /> <path id="trunk lines_3" d="M53.947 38.0527C47.2667 27.313 51.8749 15.6325 54.6584 12.087L58.3339 12.7984C55.5504 16.3439 50.8236 26.246 57.504 36.9856L53.947 38.0527Z" fill="#313131" stroke="black" /> <path id="trunk lines_4" d="M63.7528 34.6143C56.6849 26.8661 61.298 16.5925 64.38 14.6955L67.5819 15.8811C65.3292 18.6081 61.4051 23.9435 66.3963 33.1916L63.7528 34.6143Z" fill="#313131" stroke="black" /> <path id="small-wing" d="M61.4166 1.06052C55.8203 0.206853 39.1659 8.60919 32.6053 12.0871C54.3264 11.3283 59.9938 9.00435 61.4166 8.05583C63.2303 6.8467 67.0128 1.91419 61.4166 1.06052Z" fill="#99CEFF" stroke="black" /> <path id="large-wing" d="M32.9609 11.9685C48.0977 7.26541 80.3166 -2.14073 74.6957 7.34446C68.7675 14.5769 44.3036 13.6679 32.9609 11.9685Z" fill="#81D1FE" stroke="black" /> <path id="bee sting" d="M70.4275 30.7017L73.273 27.7376L76 32.7173L70.4275 30.7017Z" fill="#313131" stroke="black" /> <path id="antenna" d="M13.1606 15.8811C13.4768 12.6008 12.1173 5.73197 4.14972 4.4989M10.3151 17.8967C9.36656 14.4583 6.09418 8.05584 0.592773 9.95288" stroke="black" /> <path id="bee legs" d="M30.3525 39.1198L26.2028 43.151L28.2184 46.2337M35.6879 39.9497L31.7753 44.5738L34.2652 48.605" stroke="black" /> <circle id="antenna ball" cx="4.38689" cy="4.38033" r="0.592824" fill="#FFE818" /> <circle id="antenna ball_2" cx="0.592824" cy="9.83431" r="0.592824" fill="#FFE818" /> <path id="bee behind legs" d="M49.2044 39.2384L45.6475 43.6253L47.6631 45.9965M55.4883 37.8156L50.8643 43.6253L55.4883 46.8265" stroke="black" /> </g> </symbol> </svg> </div> </div> </div> <svg> <use xlink:href="#theBee" class="newCreatedBeeComingFromHive" width="400" height="38.4" x="-30" y="290" /> </svg> </body> </html>

$ export OPENCV4NODEJS_DISABLE_AUTOBUILD=1

,

第 1 步:使用以下命令在您的 mac 上查找 opencv lib 位置

find / -name "OpenCVConfig.cmake"

第 2 步:为您提供以下路径

/opt/homebrew/Cellar/opencv/4.5.2_4/lib

第三步:打开zshrc文件

open ~/.zshrc 

第 4 步:将以下行放入 zshrc 文件中

export OPENCV_LIB_DIR="/opt/homebrew/Cellar/opencv/4.5.2_4/lib"

第 5 步:保存并关闭 zshrc 文件 第 6 步:执行以下命令

source ~/.zshrc 

第 7 步:现在尝试做 npm i opencv4nodejs

干杯!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...