skip to Main Content

i would want to make a node.js project with opencv but i failed to install opencv4node. Can someone help me please .Here are the errors I encountered

i tried installing chocolatey, i saw it in someone’s answer ‘s post but it doesn’t work

npm install --save opencv4nodejs --build-from-source
npm warn deprecated [email protected]: This package is no longer supported.
npm warn deprecated [email protected]: This package is no longer supported.
npm warn deprecated [email protected]: This package is no longer supported.
npm error code 1
npm error path D:Local DiskstageL3backendnode_modulesopencv4nodejs
npm error command failed
npm error command C:Windowssystem32cmd.exe /d /s /c node ./install/install.js
npm error info install using lib dir: D:/Local Disk/stageL3/backend/node_modules/opencv-build/opencv/build/lib/Release
npm error D:Local DiskstageL3backendnode_modulesopencv4nodejsinstallinstall.js:37
npm error   throw new Error('library dir does not exist: ' + libDir)
npm error   ^
npm error
npm error Error: library dir does not exist: D:/Local Disk/stageL3/backend/node_modules/opencv-build/opencv/build/lib/Release
npm error     at Object.<anonymous> (D:Local DiskstageL3backendnode_modulesopencv4nodejsinstallinstall.js:37:9)
npm error     at Module._compile (node:internal/modules/cjs/loader:1469:14)
npm error     at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
npm error     at Module.load (node:internal/modules/cjs/loader:1288:32)
npm error     at Module._load (node:internal/modules/cjs/loader:1104:12)
npm error     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
npm error     at node:internal/main/run_main_module:28:49
npm error
npm error Node.js v20.17.0

2

Answers


  1. Chosen as BEST ANSWER

    Allow me to put the full error here as it couldn't fit in the comment section

    PS D:learnnode> npm install --save @u4/opencv4nodejs --force
    npm warn using --force Recommended protections disabled.
    npm warn cleanup Failed to remove some directories [
    npm warn cleanup   [
    npm warn cleanup     '\\?\D:\learnnode\node_modules\@u4\opencv- 
    build',
    npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 
    'D:[email protected]'] {
    npm warn cleanup       errno: -4048,
    npm warn cleanup       code: 'EPERM',
    npm warn cleanup       syscall: 'rmdir',
    npm warn cleanup       path: 'D:\learnnode\node_modules\@u4\opencv- 
    build\script\deps\jsr.io'
    npm warn cleanup     }
    npm warn cleanup   ]
    npm warn cleanup ]
    npm error code 1
    npm error path D:learnnodenode_modules@u4opencv4nodejs
    npm error command failed
    npm error command C:Windowssystem32cmd.exe /d /s /c node-gyp rebuild
    npm error gyp info it worked if it ends with ok
    npm error gyp info using [email protected]
    npm error gyp info using [email protected] | win32 | x64
    npm error gyp info find Python using Python version 3.9.0 found at 
    "C:UsersidealAppDataLocalProgramsPythonPython39python.exe"
    npm error gyp info find VS using VS2022 (17.11.35312.102) found at:
    npm error gyp info find VS "C:Program FilesMicrosoft Visual 
    Studio2022Community"
    npm error gyp info find VS run with --verbose for detailed information
    npm error gyp info spawn 
    C:UsersidealAppDataLocalProgramsPythonPython39python.exe
    npm error gyp info spawn args [
    npm error gyp info spawn args 'D:\learnnode\node_modules\node- 
    gyp\gyp\gyp_main.py',
    npm error gyp info spawn args 'binding.gyp',
    npm error gyp info spawn args '-f',
    npm error gyp info spawn args 'msvs',
    npm error gyp info spawn args '-I',
    npm error gyp info spawn args 
    'D:\learnnode\node_modules\@u4\opencv4nodejs\build\config.gypi',
    npm error gyp info spawn args '-I',
    npm error gyp info spawn args 'D:\learnnode\node_modules\node- 
    gyp\addon.gypi',
    npm error gyp info spawn args '-I',
    npm error gyp info spawn args 'C:\Users\ideal\AppData\Local\node- 
    gyp\Cache\22.9.0\include\node\common.gypi',
    npm error gyp info spawn args '-Dlibrary=shared_library',
    npm error gyp info spawn args '-Dvisibility=default',
    npm error gyp info spawn args '- 
    Dnode_root_dir=C:\Users\ideal\AppData\Local\node-gyp\Cache\22.9.0',
    npm error gyp info spawn args '- 
    Dnode_gyp_dir=D:\learnnode\node_modules\node-gyp',
    npm error gyp info spawn args '- 
    Dnode_lib_file=C:\\Users\\ideal\\AppData\\Local\\node- 
    gyp\\Cache\\22.9.0\\<(target_arch)\\node.lib',
    npm error gyp info spawn args '- 
    Dmodule_root_dir=D:\learnnode\node_modules\@u4\opencv4nodejs',
    npm error gyp info spawn args '-Dnode_engine=v8',
    npm error gyp info spawn args '--depth=.',
    npm error gyp info spawn args '--no-parallel',
    npm error gyp info spawn args '--generator-output',
    npm error gyp info spawn args 
    'D:\learnnode\node_modules\@u4\opencv4nodejs\build',
    npm error gyp info spawn args '-Goutput_dir=.'
    npm error gyp info spawn args ]
    npm error gyp: Call to 'node ./bin/install.js OPENCV4NODEJS_DEFINES' 
    returned exit status 1 while in binding.gyp. while trying to load 
    binding.gyp
    npm error gyp ERR! configure error
    npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
    npm error gyp ERR! stack at ChildProcess.<anonymous> 
    (D:learnnodenode_modulesnode-gyplibconfigure.js:317:18)
    npm error gyp ERR! stack at ChildProcess.emit (node:events:519:28)
    npm error gyp ERR! stack at ChildProcess._handle.onexit 
    (node:internal/child_process:293:12)
    npm error gyp ERR! System Windows_NT 10.0.22631
    npm error gyp ERR! command "C:\Program Files\nodejs\node.exe" 
    "D:\learnnode\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
    npm error gyp ERR! cwd D:learnnodenode_modules@u4opencv4nodejs
    npm error gyp ERR! node -v v22.9.0
    npm error gyp ERR! node-gyp -v v10.2.0
    npm error gyp ERR! not ok
    npm error A complete log of this run can be found in: 
    C:UsersidealAppDataLocalnpm-cache_logs2024-09-23T19_34_06_698Z- 
    debug-0.log
    

  2. It seems this error is caused by installing the package using "new" versions of node/npm. There are a lot of issues talking about this problem on the project’s Github repository, for example this one. Workarounds that might or might not lead to success include downgrading npm, installing a dependency of opencv4nodejs first, disabling automatic opencv.js building and installing node-gyp for building opencv.js automatically. You might want to search the Github issues for your error and read the discussions there for further information.

    However, as the project’s README states, it is no longer maintained and you probably shouldn’t use it. Instead, it recommends using this fork, which provides rather detailed installation instructions.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search