node-opencv
node-opencv copied to clipboard
Ubuntu npm install opencv issues
System : Ubuntu 16.04 LTS
npm : 3.5.2
node : v4.2.6
When I try to install node-opencv by running 'npm install opencv`, I get a npm warning as follows:
npm WARN lifecycle [email protected]~install: cannot run in wd %s %s (wd=%s) [email protected] node-pre-gyp install --fallback-to-build
The node_modules get created and installed but the opencv module does not have a build directory created. Hence when I try to include it by using require('opencv')
, I get this
Cannot find module
../node_modules/opencv/build/opencv/v5.0.0/Release/node-v46-linux-x64/opencv.node'
I tried cloning the master and running npm install and the same problem persists despite of running `npm build' first. How could I make this work? I have tried on a mac and the same steps work fine. Any help appreciated, Thanks!
Note: opencv is installed correctly on the system. I also have pkg_config installed and a PKG_CONFIG_PATH set to where my opencv.pc exists.
+1 same to you~ I can't find any stable installation guide
I Install Opencv On Ubuntu 14.04 With No Fail, But On CentOS 6.7 got a lot of Problem, and i spent a weak to solve the problem, I write down the script for both OS, may be it can help you.
https://github.com/Josephliao1991/LinuxPackageShell/tree/master/Opencv
I installed opencv as node modules success, when I installed gcc-4.8 and g++-4.8.1. so I suggest you have a try.
I install node_module OpenCv via npm it give error yeoman@yeoman:~/Documents/faceDetection_back$ sudo npm install opencv --save
[email protected] install /home/yeoman/Documents/faceDetection_back/node_modules/opencv node-pre-gyp install --fallback-to-build
/home/yeoman/Documents/faceDetection_back/node_modules/opencv/utils/find-opencv.js:21 throw new Error("ERROR: failed to run: pkg-config", opencv, flag); ^
Error: ERROR: failed to run: pkg-config
at /home/yeoman/Documents/faceDetection_back/node_modules/opencv/utils/find-opencv.js:21:23
at ChildProcess.exithandler (child_process.js:213:5)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.gyp
failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.2.0-36-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/yeoman/Documents/faceDetection_back/node_modules/opencv/build/opencv/v5.0.0/Release/node-v48-linux-x64/opencv.node" "--module_name=opencv" "--module_path=/home/yeoman/Documents/faceDetection_back/node_modules/opencv/build/opencv/v5.0.0/Release/node-v48-linux-x64"
gyp ERR! cwd /home/yeoman/Documents/faceDetection_back/node_modules/opencv
gyp ERR! node -v v6.5.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/yeoman/Documents/faceDetection_back/node_modules/opencv/build/opencv/v5.0.0/Release/node-v48-linux-x64/opencv.node --module_name=opencv --module_path=/home/yeoman/Documents/faceDetection_back/node_modules/opencv/build/opencv/v5.0.0/Release/node-v48-linux-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs opencv
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls opencv
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request: npm ERR! /home/yeoman/Documents/faceDetection_back/npm-debug.log
My install algo
- Delete all from system sudo apt-get remove --purge node nodejs npm node-gyp node-pre-gyp sudo apt-get autoremove
- Download and install NVM (Node version manager)
I have notice that some times ubuntu have some troubles with nvm when you install things in root mode. Unroot if needed.
// check for newest version in git repo
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash
// Update current terminal source ~/.bashrc // Check nvm version command nvm -v // Check current nvm node versions (must be empty list) nvm ls - Install nodejs // install nodejs needed version (must be > 0.10 for node-opencv i recommend 6.5+) nvm install v6.5.0 // set default node version nvm alias default v6.5.0 // check for instalation 6.5 nvm ls (NPM installs automatic with nvm)
- Opencv // install opencv ubuntu library if needed sudo apt-get install libopencv-dev npm -g install node-gyp npm -g install node-pre-gyp npm -g install opencv // or you can install it local and add to package.json //// npm --save install opencv
- also recommend install nodemon for developement and supervizor for production
There're a few different errors going on here. @firefred has a very detailed list of what to do.
@arimai, you should check node_modules/opencv/build/opencv/v5.0.0/Release
. If there's no directories, it means that node-opencv
could not be compiled at all, and you might not have OpenCV installed in the first place. If there's a directory, and it's not node-v46-linux-x64
, then it means that node-opencv
was compiled to a different node/arch setup than what you're using the script with.
@chandankrishnan it sounds like OpenCV has not been installed on your system?
I'll close this thread in some days if there's no follow-up, since there's a few solutions posted already.