我已在package.json
文件中定义了this page:
{
"name": "phash-hamming",
"version": "0.0.1",
"dependencies": {
"phash-image": "3.5.0"
}
}
在我的index.js
中,第一行会导致错误:
var phash = require('phash-image');
错误:
构建失败:退出状态1
phash-image@3.5.0 install / workspace / node_modules / phash-image node-gyp rebuild
/ bin / sh:1:pkg-config:找不到gyp:调用' pkg-config --libs-only-L --libs-only-other pHash'在binding.gyp中返回退出状态127。在尝试加载binding.gyp gyp ERR时!配置 错误gyp ERR!堆栈错误:
gyp
失败,退出代码:1 gyp ERR! 在ChildProcess.onCpExit堆栈 (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16) gyp ERR!堆栈在emitTwo(events.js:106:13)gyp ERR!堆栈在 ChildProcess.emit(events.js:191:7)gyp ERR!堆栈在 Process.ChildProcess._handle.onexit(internal / child_process.js:219:12) gyp ERR! System Linux 4.4.0-116-generic gyp ERR!命令 " /的NodeJS / bin中/节点" " /nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "重建" 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!不行
答案 0 :(得分:0)
https://github.com/mgmtio/phash-image
阅读Installation
部分。
phash-image取决于CImg,pHash,ImageMagicK。
您是否安装了上述之一?
答案 1 :(得分:0)
以下对我有用:
1.从您正在呼叫的功能中加载phash-image
库。
2.使用phash-image repo中的package.json。
您的index.js:
exports.helloWorld = (req, res) => {
var phash = require('phash-image');
};
你的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 <agm257@mail.missouri.edu>",
"contributors": [
"Aaron Marasco <agm257@mail.missouri.edu>",
"Taeho Kim <xissysnd@gmail.com>",
"Jeremy Dowell <jeremy@codevinsky.com>",
"Rod Vagg <r@va.gg> (https://github.com/rvagg)",
"Jonathan Ong <me@jongleberry.com> (https://github.com/jonathanong)"
],
"dependencies": {
"any-promise": "^1.1.0",
"nan": "^2.0.5"
},
"license": "MIT"
}