LoginSignup
2
1

More than 5 years have passed since last update.

AWS Lambda(Node.js)でGoogle Cloud Natural Language APIを使用してエラー"Failed to load gRPC"が発生したときの対応方法

Posted at

環境/ライブラリ

事象

AWS Lambda(Node.js)上の関数で、Google Cloud Natural Language APIを呼び出すとエラー"Failed to load gRPC"が発生する。

エラーログ例

Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-linux-x64-glibc
Found: [node-v57-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/opt/nodejs/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'
at Object.<anonymous> (/opt/nodejs/node_modules/grpc/src/grpc_extension.js:53:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/opt/nodejs/node_modules/grpc/src/client_interceptors.js:144:12)
at Module._compile (module.js:652:30) code: 'MODULE_NOT_FOUND

対応方法

以下のコマンドでリビルドする。targetはNode.jsのバージョンに合わせる

npm rebuild grpc —target=8.1.0 --target_arch=x64 --target_platform=linux --target_libc=glibc

感想

こういうエラーが起きると、Pythonにすれば良かったと思う(逆もまた然り)

参照

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1