GCP构建失败的gyp ERR!堆栈错误:`make`失败,退出代码:2

时间:2019-09-23 12:25:17

标签: node.js google-app-engine app-engine-flexible

我正在使用gcloud app deploy在gcp上部署我的节点应用程序。我已经安装了gcloud sdk,现在当我尝试执行deploy命令时,会导致以下错误:

Step #1: prebuild-install WARN install libusb-1.0.so.0: cannot open shared object file: No such file or directory
Step #1: make: Entering directory '/app/node_modules/node-hid/build'
Step #1: ../hidapi/linux/hid.c:44:21: fatal error: libudev.h: No such file or directory
Step #1: compilation terminated.
Step #1: hidapi-linux-hidraw.target.mk:101: recipe for target 'Release/obj.target/hidapi-linux-hidraw/hidapi/linux/hid.o' failed
Step #1: make: *** [Release/obj.target/hidapi-linux-hidraw/hidapi/linux/hid.o] Error 1
Step #1: make: Leaving directory '/app/node_modules/node-hid/build'
Step #1: gyp ERR! build error 
Step #1: gyp ERR! stack Error: `make` failed with exit code: 2
Step #1: gyp ERR! stack     at ChildProcess.onExit (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
Step #1: gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
Step #1: gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
Step #1: gyp ERR! System Linux 4.15.0-1044-gcp
Step #1: gyp ERR! command "/nodejs/bin/node" "/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
Step #1: gyp ERR! cwd /app/node_modules/node-hid
Step #1: gyp ERR! node -v v10.16.1
Step #1: gyp ERR! node-gyp -v v3.8.0
Step #1: gyp ERR! not ok 
Step #1: npm WARN bridge@1.0.0 No description
Step #1: npm WARN bridge@1.0.0 No repository field.
Step #1: 
Step #1: npm ERR! code ELIFECYCLE
Step #1: npm ERR! errno 1
Step #1: npm ERR! node-hid@0.7.9 install: `prebuild-install || node-gyp rebuild`
Step #1: npm ERR! Exit status 1
Step #1: npm ERR! 
Step #1: npm ERR! Failed at the node-hid@0.7.9 install script.

它从节点隐藏错误开始。我用npm install --save node-hid安装了它。然后变成上面提到的错误。

以下是我的package.json

{
  "name": "bridge",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "engines": {
    "node": "10.16.3"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@binance-chain/javascript-sdk": "^2.14.8",
    "axios": "^0.19.0",
    "bignumber.js": "^5.0.0",
    "bip39": "^3.0.2",
    "body-parser": "^1.19.0",
    "compression": "^1.7.4",
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "crypto-browserify": "^3.12.0",
    "express": "^4.17.1",
    "generate-password": "^1.4.2",
    "helmet": "^3.21.0",
    "mongoose": "^5.6.11",
    "node-fetch": "^2.6.0",
    "node-hid": "^0.7.9",
    "nodemailer": "^6.3.0",
    "prebuild-install": "^5.3.2",
    "react": "^16.9.0",
    "sha256": "^0.2.0",
    "web3": "^1.2.1"
  }
}

还有app.yaml

runtime: nodejs
env: flex

# manual_scaling:
#   instances: 1

# resources:
#   cpu: .5
#   memory_gb: 0.5
#   disk_size_gb: 10

# handlers:
#   -url: /
#     static_files: client/build/index.html
#     upload: client/build/index.html
#   -url: /
#     static_dir: client/build

在本地环境下一切正常,但是在部署到云时会产生错误。

1 个答案:

答案 0 :(得分:1)

我有类似的问题(在MAC OS中),原因是将包文件锁定在项目文件夹中,因此产生了冲突。尝试删除

package-lock.json

从项目文件夹开始,而不是再次开始安装:

npm install

我希望对您有所帮助。