Reputation: 2909
I've defined my npm dependency in the package.json
file:
{
"name": "phash-hamming",
"version": "0.0.1",
"dependencies": {
"phash-image": "3.5.0"
}
}
In my index.js
the first line causes an error:
var phash = require('phash-image');
The Error:
Build failed: exit status 1
[email protected] install /workspace/node_modules/phash-image node-gyp rebuild
/bin/sh: 1: pkg-config: not found gyp: Call to 'pkg-config --libs-only-L --libs-only-other pHash' returned exit status 127 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error:
gyp
failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/nodejs/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:219:12) gyp ERR! System Linux 4.4.0-116-generic gyp ERR! command "/nodejs/bin/node" "/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /workspace/node_modules/phash-image gyp ERR! node -v v6.11.5 gyp ERR! node-gyp -v v3.4.0 gyp ERR! not ok
Upvotes: 0
Views: 208
Reputation: 1916
The following worked for me:
1.Load the phash-image
library from inside the function you are calling.
2.Use the package.json from the phash-image repo.
Your index.js:
exports.helloWorld = (req, res) => {
var phash = require('phash-image');
};
Your package.json:
{
"name": "phash-image",
"version": "3.5.0",
"description": "phash for images",
"repository": "mgmtio/phash-image",
"devDependencies": {
"bluebird": "^3.1.5",
"hamming-distance": "^1.0.0",
"istanbul": "^0.4.2",
"mocha": "^3.0.0",
"node-gyp": "^3.3.0"
},
"script": {
"preinstall": "node-gyp configure build",
"preuninstall": "rm -rf build/*"
},
"scripts": {
"build": "node-gyp configure build",
"test": "npm run build && mocha",
"test-cov": "npm run build && istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
"test-travis": "npm run build && istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
},
"keywords": [
"pHash",
"phash",
"libpHash",
"native",
"binding",
"addon"
],
"author": "Aaron Marasco <[email protected]>",
"contributors": [
"Aaron Marasco <[email protected]>",
"Taeho Kim <[email protected]>",
"Jeremy Dowell <[email protected]>",
"Rod Vagg <[email protected]> (https://github.com/rvagg)",
"Jonathan Ong <[email protected]> (https://github.com/jonathanong)"
],
"dependencies": {
"any-promise": "^1.1.0",
"nan": "^2.0.5"
},
"license": "MIT"
}
Upvotes: 0
Reputation:
https://github.com/mgmtio/phash-image
Read the Installation
section.
phash-image depends on CImg, pHash, ImageMagicK.
Do you have install one of above?
Upvotes: 0