UrielCh / opencv4nodejs

ESM Nodejs bindings to OpenCV 3/4
MIT License
224 stars 46 forks source link

Still tries to build OpenCV even when already installed by chocolately on Windows #149

Open liftyourgame opened 2 weeks ago

liftyourgame commented 2 weeks ago

Have installed OpenCV on Windows by Chocolately in PowerShell:

choco install OpenCV -y -version 4.1.0

Set environment variable system wide: OPENCV4NODEJS_DISABLE_AUTOBUILD=1

Install @u4/opencv4nodejs

npm install @u4/opencv4nodejs

Get this in the logs: and can't see node-gyp rebuild is running

`PS C:\Development\cctv> npm i npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. npm warn deprecated npmlog@7.0.1: This package is no longer supported. npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead npm warn deprecated rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported npm warn deprecated are-we-there-yet@4.0.2: This package is no longer supported. npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead npm warn deprecated gauge@5.0.2: This package is no longer supported. npm warn cleanup Failed to remove some directories [ npm warn cleanup [ npm warn cleanup 'C:\Development\cctv\node_modules', npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Development\cctv\node_modules\@isaacs\cliui\build'] { npm warn cleanup errno: -4048, npm warn cleanup code: 'EPERM', npm warn cleanup syscall: 'rmdir', npm warn cleanup path: 'C:\Development\cctv\node_modules\@isaacs\cliui\build' npm warn cleanup } npm warn cleanup ], npm warn cleanup [ npm warn cleanup 'C:\Development\cctv\node_modules\@u4', npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\node_modules\eslint'] { npm warn cleanup errno: -4048, npm warn cleanup code: 'EPERM', npm warn cleanup syscall: 'rmdir', npm warn cleanup path: 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\node_modules\eslint' npm warn cleanup } npm warn cleanup ] npm warn cleanup ] npm error code 1 npm error path C:\Development\cctv\node_modules\@u4\opencv4nodejs npm error command failed npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild npm error opencv4nodejs.cc npm error CustomMatAllocator.cc npm error ExternalMemTracking.cc npm error core.cc npm error coreConstants.cc npm error HistAxes.cc npm error Mat.cc npm error Point.cc npm error Vec.cc npm error Size.cc npm error Rect.cc npm error RotatedRect.cc npm error TermCriteria.cc npm error imgproc.cc npm error imgprocConstants.cc npm error MatImgproc.cc npm error Contour.cc npm error Moments.cc npm error calib3d.cc npm error calib3dConstants.cc npm error MatCalib3d.cc npm error io.cc npm error ioConstants.cc npm error VideoCapture.cc npm error VideoWriter.cc npm error photo.cc npm error photoConstants.cc npm error MatPhoto.cc npm error video.cc npm error BackgroundSubtractor.cc npm error BackgroundSubtractorMOG2.cc npm error BackgroundSubtractorKNN.cc npm error ximgproc.cc npm error MatXimgproc.cc npm error SuperpixelSEEDS.cc npm error SuperpixelSLIC.cc npm error SuperpixelLSC.cc npm error objdetect.cc npm error CascadeClassifier.cc npm error HOGDescriptor.cc npm error DetectionROI.cc npm error machinelearning.cc npm error machinelearningConstants.cc npm error ParamGrid.cc npm error StatModel.cc npm error SVM.cc npm error TrainData.cc npm error dnn.cc npm error Net.cc npm error C:\Development\cctv\node_modules\@u4\opencv4nodejs\cc\dnn\Net.cc(115,48): error C2039: 'dump': is not a member of 'cv::dnn::dnn4_v20190122::Net' [C:\Development\cctv\node_modules\@u4\opencv4nodejs\build\opencv4nodejs.vcxproj] npm error gyp info it worked if it ends with ok npm error gyp info using node-gyp@10.1.0 npm error gyp info using node@20.15.0 | win32 | x64 npm error gyp info find Python using Python version 3.12.4 found at "C:\Python312\python.exe" npm error gyp info find VS using VS2022 (17.10.35013.160) found at: npm error gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" npm error gyp info find VS run with --verbose for detailed information npm error gyp info spawn C:\Python312\python.exe npm error gyp info spawn args [ npm error gyp info spawn args 'C:\Development\cctv\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 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\build\config.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args 'C:\Development\cctv\node_modules\node-gyp\addon.gypi', npm error gyp info spawn args '-I', npm error gyp info spawn args 'C:\Users\greg\AppData\Local\node-gyp\Cache\20.15.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\greg\AppData\Local\node-gyp\Cache\20.15.0', npm error gyp info spawn args '-Dnode_gyp_dir=C:\Development\cctv\node_modules\node-gyp', npm error gyp info spawn args '-Dnode_lib_file=C:\\Users\\greg\\AppData\\Local\\node-gyp\\Cache\\20.15.0\\<(target_arch)\\node.lib', npm error gyp info spawn args '-Dmodule_root_dir=C:\Development\cctv\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 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\build', npm error gyp info spawn args '-Goutput_dir=.' npm error gyp info spawn args ] npm error gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe npm error gyp info spawn args [ npm error gyp info spawn args 'build\binding.sln', npm error gyp info spawn args '/clp:Verbosity=minimal', npm error gyp info spawn args '/nologo', npm error gyp info spawn args '/p:Configuration=Release;Platform=x64' npm error gyp info spawn args ] npm error gyp ERR! build error npm error gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1 npm error gyp ERR! stack at ChildProcess. (C:\Development\cctv\node_modules\node-gyp\lib\build.js:209:23) 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:294:12) npm error gyp ERR! System Windows_NT 10.0.22631 npm error gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Development\cctv\node_modules\node-gyp\bin\node-gyp.js" "rebuild" npm error gyp ERR! cwd C:\Development\cctv\node_modules\@u4\opencv4nodejs npm error gyp ERR! node -v v20.15.0 npm error gyp ERR! node-gyp -v v10.1.0 npm error gyp ERR! not ok

npm error A complete log of this run can be found in: C:\Users\greg\AppData\Local\npm-cache_logs\2024-07-03T05_18_45_353Z-debug-0.log PS C:\Development\cctv> `

UrielCh commented 2 weeks ago

That's not the first time I saw this kind of error, do you have an anti-virus running on your system that may cause errors during the cleaning step? Try to disable the antivirus live protect and check if you have the same issue.

liftyourgame commented 2 weeks ago

Thanks. Disabled Malwarebytes but still get the error. I don't think deleting is the problem is it? Why is it trying to build OpenCV when the OPENCV4NODEJS_DISABLE_AUTOBUILD flag is set to 1?

studentutu commented 2 weeks ago

same here, fixed it by using pnpm - somehow default npm tries to build lib even when all conditions to disable autobuild are met.

liftyourgame commented 2 weeks ago

Did:

choco install pnpm
pnpm install

Still get the same result.

studentutu commented 2 weeks ago

try to clean all npm caches and such, and also remove ./node-modules - and strictly use pnpm - it will use symlinked folders in your ./node-module, this is probably why it works with pnpm Also install globally nody-gyp or something like this ( see the package for opencv4nodejs), as it is one of the requirements for build project

liftyourgame commented 2 weeks ago

So did:

npm cache clean --force
del node_modules
pnpm install -g node-gyp

pnpm install

Get the same result

liftyourgame commented 5 days ago

Ran:

Remove-Item .\node_modules\

$env:OPENCV4NODEJS_DISABLE_AUTOBUILD=1
$env:OPENCV_INCLUDE_DIR='C:\\tools\\opencv\\build\\include'
$env:OPENCV_LIB_DIR='C:\tools\opencv\build\x64\vc15\lib'
$env:OPENCV_BIN_DIR='C:\tools\opencv\build\x64\vc15\bin'

pnpm i

Still get:

node_modules/.pnpm/@u4+opencv4nodejs@7.1.0_typescript@5.5.3/node_modules/@u4/opencv4nodejs: Running install script, failed in 1m 41.1s
.../node_modules/@u4/opencv4nodejs install$ node-gyp rebuild

Why is node-gyp rebuild running?

Seems to be starting around line 319 of compileLib.js

tothadi commented 4 days ago

Same here since version 7.0.0. I have a custom docker image with prebuild opencv but npm ci still tries to build everytime and gyp fails every time.