【问题标题】:GCP Build failed gyp ERR! stack Error: `make` failed with exit code: 2GCP 构建失败 gyp ERR!堆栈错误:`make` 失败,退出代码:2
【发布时间】:2020-01-23 12:30:38
【问题描述】:

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

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

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

【问题讨论】:

  • 根据消息的第一行你正在寻找libsub-1.0库,这个库没有在你的依赖中声明,也没有在应用引擎环境中默认出现,你可以看看本文档解释了如何使用包管理器:cloud.google.com/appengine/docs/flexible/nodejs/…

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


【解决方案1】:

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

package-lock.json

从项目文件夹而不是再次启动安装:

npm install

希望对你也有帮助。

【讨论】:

  • 我不理解对此的负面评论,因为我遇到了上述问题。请在发表负面评论时留下 cmets,以便人们决定谁错了。
  • 此外,我的评论是云实现,这很可能是 UNIX/ LINUX 服务器,可能会导致类似的问题,而 WIN 由于权限可以忽略问题。
猜你喜欢
  • 2023-01-19
  • 1970-01-01
  • 1970-01-01
  • 2021-06-26
  • 1970-01-01
  • 2021-08-15
  • 1970-01-01
  • 1970-01-01
  • 2021-08-09
相关资源
最近更新 更多