Start with node-gyp
You can install with npm
:
$ npm install -g node-gyp
You will also need to install:
From an elevated PowerShell or CMD.exe (run as Administrator), install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools
.
If you already have Visual Studio installed, then Visual Studio Build Tools
may fail. In that case launch cmd and enter npm config set msvs_version 2017
.
Install tools and configuration manually:
- Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2017 Community (using the "Desktop development with C++" workload)
- Install Python 2.7 (
v3.x.x
is not supported), and runnpm config set python python2.7
(or see below for further instructions on specifying the proper Python version and path.) - Launch cmd,
npm config set msvs_version 2017
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.
If you have multiple Python versions installed, you can identify which Python
version node-gyp
uses by setting the '--python' variable:
$ node-gyp --python /path/to/python2.7
If node-gyp
is called by way of npm
, and you have multiple versions of
Python installed, then you can set npm
's 'python' config key to the appropriate
value:
$ npm config set python /path/to/executable/python2.7
If windows-build-tools
was installed, the Python 2.7 path should be C:\Users\<user>\.windows-build-tools\python27\
.
Use the command below to check npm
's 'python' config key value:
$ npm config get python
Download and install x64
version from: CMake Downloads
Add to PATH
during install
Will need to execute remaining commands in new terminal for cmake
to be recognized. Use cmake --version
to confirm that it's installed and available.
Install opencv4nodejs:
Verify that git is installed by using git --version
; install if necessary.
If you do not want to set up OpenCV on your own you can simply let this package auto install OpenCV 3.4 + OpenCV contrib 3.4 (might take some time):
$ npm i -g opencv4nodejs
I've gotten errors about Visual Studio on a clean install (using just the windows-build-tools; not Visual Studio), and resolved that with a restart. I had also installed Visual Studio Build Tools, but the restart might have been all that was needed.
In order to prevent build errors during an npm install
, your package.json
should not include opencv4nodejs
, and instead should include/require the global package either by requiring it by absolute path or setting the NODE_PATH
environment variable to /usr/lib/node_modules
in your Dockerfile and requiring the package as you normally would.
I chose to add a NODE_PATH
environment variable. The install path will be displayed in the output of the previous command, but for me it was in C:\Users\<user>\AppData\Roaming\npm\node_modules
.
Hi need help, I am new to testing and trying to work with Appium. When I run appium doctor I am getting the following result, kindly advice:
Kindly help me with "opencv4nodejs cannot be found." I am using Windows 11.
C:\Users\nshij>appium-doctor
WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global"
info AppiumDoctor Appium Doctor v.1.16.2
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ✔ The Node.js binary was found at: C:\Program Files\nodejs\node.EXE
info AppiumDoctor ✔ Node version is 18.9.1
info AppiumDoctor ✔ ANDROID_HOME is set to: C:\Users\nshij\AppData\Local\Android\Sdk
info AppiumDoctor ✔ JAVA_HOME is set to: C:\Program Files\Java\jdk-19
info AppiumDoctor Checking adb, android, emulator, apkanalyzer.bat
info AppiumDoctor 'adb' is in C:\Users\nshij\AppData\Local\Android\Sdk\platform-tools\adb.exe
info AppiumDoctor 'android' is in C:\Users\nshij\AppData\Local\Android\Sdk\tools\android.bat
info AppiumDoctor 'emulator' is in C:\Users\nshij\AppData\Local\Android\Sdk\emulator\emulator.exe
info AppiumDoctor 'apkanalyzer.bat' is in C:\Users\nshij\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\apkanalyzer.bat
info AppiumDoctor ✔ adb, android, emulator, apkanalyzer.bat exist: C:\Users\nshij\AppData\Local\Android\Sdk
info AppiumDoctor ✔ 'bin' subfolder exists under 'C:\Program Files\Java\jdk-19'
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor ✖ opencv4nodejs cannot be found.
info AppiumDoctor ✔ ffmpeg is installed at: C:\Program Files\ffmpeg\ffmpeg-5.1.2-essentials_build\bin\ffmpeg.EXE. ffmpeg version 5.1.2-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
info AppiumDoctor ✔ mjpeg-consumer is installed at: C:\Users\nshij\AppData\Roaming\npm. Installed version is: 2.0.0
info AppiumDoctor ✔ bundletool.jar is installed at: C:\Users\nshij\AppData\Local\Android\Sdk\bundle-tools\bundletool.jar
info AppiumDoctor ✔ gst-launch-1.0.exe and gst-inspect-1.0.exe are installed at: D:\gstreamer\1.0\msvc_x86_64\bin\gst-launch-1.0.exe and D:\gstreamer\1.0\msvc_x86_64\bin\gst-inspect-1.0.exe
info AppiumDoctor ### Diagnostic for optional dependencies completed, one fix possible. ###
info AppiumDoctor
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it: http://appium.io/docs/en/writing-running-appium/image-comparison/
info AppiumDoctor
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!