gpt4 book ai didi

node.js - 由于 gRPC,无法在 Node Alpine Docker 容器中使用 @google-cloud/logging

转载 作者:太空宇宙 更新时间:2023-11-03 23:21:29 30 4
gpt4 key购买 nike

我有一个基于 node#8.9.4-alpine 的 Docker 镜像,用于我的 Sails.js 项目。我刚刚安装了 @google-cloud/logging NPM 包并在我的项目中对其进行了初始化,但我在控制台中收到以下错误:

web-service_1  | error: Error: Failed to load gRPC binary module because it was not installed for the current system
web-service_1 | Expected directory: node-v57-linux-x64-musl
web-service_1 | Found: [node-v57-darwin-x64-unknown]
web-service_1 | This problem can often be fixed by running "npm rebuild" on the current system
web-service_1 | Original error: Cannot find module '/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node'
web-service_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/grpc_extension.js:53:17)
web-service_1 | at Module._compile (module.js:643:30)
web-service_1 | at Object.Module._extensions..js (module.js:654:10)
web-service_1 | at Module.load (module.js:556:32)
web-service_1 | at tryModuleLoad (module.js:499:12)
web-service_1 | at Function.Module._load (module.js:491:3)
web-service_1 | at Module.require (module.js:587:17)
web-service_1 | at require (internal/module.js:11:18)
web-service_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/client.js:37:12)
web-service_1 | at Module._compile (module.js:643:30)
web-service_1 | at Object.Module._extensions..js (module.js:654:10)
web-service_1 | at Module.load (module.js:556:32)
web-service_1 | at tryModuleLoad (module.js:499:12)
web-service_1 | at Function.Module._load (module.js:491:3)
mongoDb_1 | 2018-03-09T11:39:52.522+0000 I NETWORK [conn11] end connection 172.18.0.2:51022 (0 connections now open)
web-service_1 | at Module.require (module.js:587:17)
web-service_1 | at require (internal/module.js:11:18)
web-service_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/index.js:30:14)
web-service_1 | at Module._compile (module.js:643:30)
web-service_1 | at Object.Module._extensions..js (module.js:654:10)
web-service_1 | at Module.load (module.js:556:32)
web-service_1 | at tryModuleLoad (module.js:499:12)
web-service_1 | at Function.Module._load (module.js:491:3)

据我了解,这是因为基于 musl 的 Alpine Linux 中不包含 gRPC。我对此很陌生,非常感谢有关如何解决此问题的任何帮助。这就是我的 Dockerfile 的样子:

FROM node:8.9.4-alpine
LABEL Name=web-service Version=1.0.0

# Container configuration
ENV NODE_ENV development
WORKDIR /usr/src/app
RUN npm install -g sails@0.12.4 grunt@1.0.1 nodemon@1.14.11
VOLUME /usr/src/app
EXPOSE 1337
CMD ["nodemon"]

我尝试执行 npm install grpc 但这也没有帮助。谢谢。

最佳答案

您缺少 libstdc++ Alpine 软件包。以下 Dockerfile 应该可以工作:

FROM node:alpine
RUN apk add --no-cache libstdc++
RUN npm install --save @google-cloud/logging

关于node.js - 由于 gRPC,无法在 Node Alpine Docker 容器中使用 @google-cloud/logging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49193227/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com