无法运行require('opencv4nodejs ')

c86crjj0  于 2023-08-06  发布在  其他
关注(0)|答案(1)|浏览(183)

我使用的是macOS Monterey 12.2.1,Apple M1。在项目目录中,我通过以下脚本代码安装了opencv-build和opencv 4 nodejs:
第一个月
当我运行cv = require('opencv4nodejs')时,我得到了这个错误消息,我无法理解它。如何正确运行此代码?

/usr/local/bin/node /Users/david/Desktop/project2/main.js
/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js:47
    throw err
    ^

Error: Cannot find module '/Users/david/Desktop/project2/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:
- /Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js
- /Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/opencv4nodejs.js
- /Users/david/Desktop/project2/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js:40:8)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js',
    '/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/opencv4nodejs.js',
    '/Users/david/Desktop/project2/main.js'
  ]
}

Process finished with exit code 1

字符串

blmhpbnm

blmhpbnm1#

使用Node 14.18.1,然后卸载opencv4nodejs。
运行export CXXFLAGS="-std=c++14 -Wno-c++11-narrowing"
运行npm install opencv4nodejs

相关问题