ItayB ItayB - 4 months ago 54
Javascript Question

Error: Cannot find module 'google-protobuf'

Following to my previous question, I'm trying to use protocol buffers in node.js. I've generated

ServiceMessage_pb.js
from my
ServiceMessage.proto
, and add the following code:

var messages = require('./ServiceMessage_pb');


Now I'm getting the following error in my node log:

Error: Cannot find module 'google-protobuf'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/aii/ws/ServiceMessage_pb.js:8:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)


Any suggestions how to solve this?

Thanks

Answer

You can install the module with npm:

npm install --save protobuf

The require it this whay:

var protobuff = require("protobuf");
Comments