opencv-build is an npm package designed to automate the compilation of the native OpenCV library, including its `contrib` modules, from source code. It primarily serves as a crucial build dependency for Node.js projects that integrate with OpenCV, most notably `opencv4nodejs`. This package abstracts away the complex, platform-specific steps of fetching OpenCV source, configuring the build with CMake, and compiling the binaries, which is vital for enabling computer vision capabilities in Node.js applications across different operating systems. While the specific version `0.1.9` is older, the underlying build automation approach is still actively maintained and evolved, often through similar packages like `@u4/opencv-build` for current `opencv4nodejs` versions. Its key differentiator is providing a configurable, automated native build process for a significant external dependency, streamlining development workflows by minimizing manual native compilation efforts and ensuring compatibility with the Node.js runtime. Releases are typically tied to the needs of `opencv4nodejs` and OpenCV's own release cycle, without a strict independent cadence.
npm install opencv-buildNo compatibility data collected yet for this library.
This quickstart demonstrates how to configure `opencv-build` via the `package.json` for an `opencv4nodejs` project, enabling custom OpenCV versions and build flags. `opencv-build` executes during `npm install` of `opencv4nodejs`.
Ensure `cmake` is installed globally (`npm install -g cmake` or via system package manager). On Windows, run `npm install --global windows-build-tools` or install Visual Studio with C++ development workload.
Allocate sufficient time and disk space. Consider using a dedicated build directory outside `node_modules` (e.g., via `OPENCV_BUILD_ROOT` environment variable) to prevent duplicate builds and allow sharing between projects or for persistence. For production, consider pre-built binaries if available.
Refer to the `opencv4nodejs` documentation for the most up-to-date and correct environment variable names and `package.json` structure (e.g., `autoBuildOpencvVersion`, `autoBuildWithoutContrib`, `autoBuildFlags`). Ensure that environment variables are correctly set for your shell/OS before running `npm install`.
For new projects or if encountering issues, consider using the more current `@u4/opencv4nodejs` which often bundles its own up-to-date build script or uses `@u4/opencv-build` internally. Migrate to modern `opencv4nodejs` versions and their recommended build mechanisms.
Install `cmake` globally. On Linux/macOS: `sudo apt-get install cmake` or `brew install cmake`. On Windows: download from `cmake.org` or use `npm install -g windows-build-tools` (which helps with Visual Studio) and ensure `cmake` is added to PATH.
Run `npm install --global windows-build-tools` to install VS2015 build tools, or ensure a compatible Visual Studio version with C++ development workload is installed. Also, check that the installation directory for `opencv4nodejs` is not `C:\Program Files` or similar restricted path.
Review the full error log for more specific details. Ensure all required development packages (e.g., `build-essential`, `pkg-config`, image/video libraries on Linux) are installed. Check for sufficient RAM and disk space. Verify `package.json` configuration or environment variables for `opencv-build` are correct.
Run `npm install` with appropriate permissions (e.g., `sudo npm install` on Linux/macOS, or ensuring your user has write access to the project directory). Alternatively, configure an `OPENCV_BUILD_ROOT` environment variable to point to a user-writable directory outside `node_modules`.