at backyard

Color my life with the chaos of trouble.

Node.jsでgRPCを試そうとしたら、Failed to load gRPC binary module because it was not installed for the current systemというエラーが出た

下記の公式を読みながらNode.jsでgRPCを試そうとしたら下記のようなエラーが出た。

grpc.io

Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v72-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system

エラーメッセージに書かれている通りに、下記のコマンドを実行する

npm rebuild

実行してから再度試すとエラーが解消された。

npm rebuildコマンドとは?

https://docs.npmjs.com/cli/rebuild

どうやら名前の通り、C++のアドオンなどのビルドを再度行ってくれるようなコマンドのよう。
新しいversionのNode.jsをインストールしたときなど、もしこのようなエラーが出たら npm rebuild コマンドの出番かも。