Failed to load gRPC binary module

3,075 views
Skip to first unread message

stef...@gmail.com

unread,
Apr 19, 2018, 4:41:51 PM4/19/18
to grpc.io
I am trying to use gRPC for the first time but I am getting following error:

Uncaught Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: electron-v1.8-linux-x64-glibc
Found: [node-v57-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/home/stefan/Work/myproj/node_modules/grpc/src/node/extension_binary/electron-v1.8-linux-x64-glibc/grpc_node.node'
    at Object.<anonymous> (/home/stefan/Work/myproj/node_modules/grpc/src/grpc_extension.js:53:17)
    at Object.<anonymous> (/home/stefan/Work/myproj/node_modules/grpc/src/grpc_extension.js:63:3)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/stefan/Work/ElectroNGL/node_modules/grpc/src/client.js:37:12)


I checked and my node.js version should be supported
$ node --version
v8.9.3


Could you help me out with this?

Thanks!

Spencer Fang

unread,
Apr 19, 2018, 6:40:57 PM4/19/18
to stef...@gmail.com, grpc.io
Can you share the commands you ran that led to this error?

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/9fa9c6cc-0d1d-49ee-b81e-b3d7a0bbed58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Spencer Fang

Stefan Doerr

unread,
Apr 20, 2018, 3:34:49 AM4/20/18
to Spencer Fang, grpc.io
Sure. I tried using it through Electron. So I just start the main.js with electron and get the error in the js console.

```
main.js

'use strict';

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

require('electron-debug')({showDevTools: true});

var mainWindow = null;

app.on('ready', function() {
    mainWindow = new BrowserWindow({
        height: 600,
        width: 800,
    });

    mainWindow.loadURL('file://' + __dirname + '/app/webapp.html');
    mainWindow.setMenu(null);
});
```

```
webapp.html

<!DOCTYPE html>
<html lang="en">
<head>
  <title>webapp</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  <link rel="stylesheet" href="css/font-awesome.min.css" />
  <link rel="stylesheet" href="css/main.css" />
  <link rel="subresource" href="css/light.css" />
  <link rel="subresource" href="css/dark.css" />
</head>
<body>
<!-- Insert this line above script imports  -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>

<!-- normal script imports etc  -->
  <!-- NGL -->
  <script src="dist/ngl.js"></script>

  <!-- UI -->
  <script src="js/lib/signals.min.js"></script>
  <script src="js/lib/tether.min.js"></script>
  <script src="js/lib/colorpicker.min.js"></script>
  <script src="js/ui/ui.js"></script>
  <script src="js/ui/ui.extra.js"></script>
  <script src="js/ui/ui.ngl.js"></script>
  <script src="js/gui.js"></script>

<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
</body>
<script>

    //var PROTO_PATH = __dirname + '/../communication.proto';
    var PROTO_PATH = '../communication.proto';
    var grpc = require('grpc');
    var hello_proto = grpc.load(PROTO_PATH).helloworld;

    /**
     * Implements the SayHello RPC method.
     */
    function sayHello(call, callback) {
      callback(null, {message: 'Hello ' + call.request.name});
    }

    /**
     * Starts an RPC server that receives requests for the Greeter service at the
     * sample server port
     */
    function main() {
      var server = new grpc.Server();
      server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
      server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
      server.start();
    }

    main();
    console.log('Started server?')
</script>
</html>
```

To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/9fa9c6cc-0d1d-49ee-b81e-b3d7a0bbed58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Spencer Fang

Stefan Doerr

unread,
Apr 20, 2018, 3:41:53 AM4/20/18
to Spencer Fang, grpc.io
Same problem actually if I move the require('grpc') inside of main.js

```
main.js

'use strict';

var grpc = require('grpc');
const electron = require('electron');
```

Throws the same error

Stefan Doerr

unread,
Apr 20, 2018, 3:47:15 AM4/20/18
to Spencer Fang, grpc.io
Seems like because it is called through electron and not through node.js it tries to look in the wrong folder for the extension binary!


Expected directory: electron-v1.8-linux-x64-glibc
Found: [node-v57-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/home/stefan/Work/ElectroNGL/node_modules/grpc/src/node/extension_binary/electron-v1.8-linux-x64-glibc/grpc_node.node'

But this folder doesn't exist. Would I be able to force it to look for it in node-v57-linux-x64-glibc?

Stefan Doerr

unread,
Apr 20, 2018, 3:51:07 AM4/20/18
to Spencer Fang, grpc.io
Okay I see this is a known problem with electron https://github.com/grpc/grpc/issues/6138
I'll continue my search over there. I thought since electron is based on node.js it should work from inside it.

Stefan Doerr

unread,
Apr 20, 2018, 4:01:54 AM4/20/18
to Spencer Fang, grpc.io
I found the solution! You need to install grpc specifically for electron with this command
npm install grpc --runtime=electron --target=[VERSION]
After that it worked with a minor fix to my html file where it had a wrong path.
Awesome!

Spencer Fang

unread,
Apr 20, 2018, 11:37:18 AM4/20/18
to stef...@gmail.com, grpc.io
Great! Thank you for sharing your solution with the community.

To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/9fa9c6cc-0d1d-49ee-b81e-b3d7a0bbed58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Spencer Fang







--
Spencer Fang
Reply all
Reply to author
Forward
0 new messages