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.