在电子中使用gRPC

jab*_*key 5 node.js grpc electron electron-builder

我试图在电子应用程序中要求grpc,但我收到以下错误:

Error: dlopen(/srv/node_modules/grpc/src/node/extension_binary/grpc_node.node, 1): Symbol not found: _GENERAL_NAME_free
  Referenced from: /srv/node_modules/grpc/src/node/extension_binary/grpc_node.node
  Expected in: flat namespace
Run Code Online (Sandbox Code Playgroud)

我正在使用OSX Sierra 10.12.1,节点6.8.1,电子1.4.4和grpc 1.0.1-pre1.

我升级了xcode命令行工具并进行了brew安装openssl --force.

我建立了二进制文件:

LDFLAGS=-L/usr/local/opt/openssl/lib CPPFLAGS=-I/usr/local/opt/openssl/include ./node_modules/.bin/electron-rebuild
Run Code Online (Sandbox Code Playgroud)

并手动:

LDFLAGS=-L/usr/local/opt/openssl/lib CPPFLAGS=-I/usr/local/opt/openssl/include HOME=~/.electron-gyp node-pre-gyp rebuild --target=1.4.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,我仍然得到错误.

San*_*rde 4

像这样重建 grpc 模块

npm install --save-dev electron-rebuild

(On Mac & Linux)
./node_modules/.bin/electron-rebuild
(On Windows)
.\node_modules\.bin\electron-rebuild.cmd
Run Code Online (Sandbox Code Playgroud)

这将重建 GRPC,您就可以开始了。