opencv4nodejs icon indicating copy to clipboard operation
opencv4nodejs copied to clipboard

package.json should have a preinstall script for opencv-build

Open brcarp opened this issue 11 months ago • 0 comments

install.js is expecting @u4/opencv-build to be installed, and even though it's listed under dependencies those dependencies haven't necessarily been resolved at the point in time when install.js is run. A solution might be to include a preinstall script like this:

  "scripts": {
    "preinstall": "npm install @u4/opencv-build",
  }

... or more robustly (to avoid an install loop):

  "scripts": {
    "preinstall": "node -e \"try{require('@u4/opencv-build')}catch(e){require('child_process').execSync('npm install @u4/opencv-build')}\""
  }

For my install, installing @u4/opencv-build resolves the gyp error that a lot of other issues are referencing:

gyp: Call to 'node ./bin/install.js OPENCV4NODEJS_DEFINES' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

brcarp avatar Feb 06 '25 07:02 brcarp