1

I have a node#8.9.4-alpine based Docker image that I am using for my Sails.js project. I just installed the @google-cloud/logging NPM package and initialized it in my project but I get the following error in my console:

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)

I understand this is because gRPC is not included with the musl-based Alpine Linux. I'm new to this and would appreciate any help on how I can fix this issue. This is what my Dockerfile looks like:

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"]

I tried doing npm install grpc but that didn't help either. Thanks.

JackH
  • 4,613
  • 4
  • 36
  • 61
  • This looks like a duplicate, see my answer https://stackoverflow.com/a/53380800/667055 – DeeZone Nov 20 '18 at 23:03
  • Possible duplicate of ["Failed to load gRPC binary module" error when running a Sails.js application inside a Docker container](https://stackoverflow.com/questions/52721947/failed-to-load-grpc-binary-module-error-when-running-a-sails-js-application-in) – DeeZone Nov 20 '18 at 23:05

1 Answers1

2

You are missing the libstdc++ Alpine package. The following Dockerfile should work:

FROM node:alpine
RUN apk add --no-cache libstdc++
RUN npm install --save @google-cloud/logging
Matt-y-er
  • 659
  • 7
  • 14
  • Unfortunately, that didn't help. I still see the same error. I even ran `docker system prune --volumes -f` to make sure I wan't calling some kind of cache but the error remains. Does libstdc++ contain the required grpc dependencies? – JackH Mar 26 '18 at 08:12
  • seems unlikely to work because Alpine is all about getting rid of crufty old libc – Randy L Aug 09 '18 at 18:30
  • I just tried building the Dockerfile and it still works. (versions: docker: node:alpine: cd4fae427afc, apk package: llibstdc++-8.3.0-r0 x86_64 {gcc}, node package: @google-cloud/logging@4.5.2). Could you let me know what you tried exactly and what's the error message? – Matt-y-er Apr 22 '19 at 15:49