Reputation: 11347
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
Upvotes: 2
Views: 12354
Reputation: 506
npm i google-protobuf
I run into so many problem installing just "protobuf" !
Also the official protobuf javascript package is "google-protobuf": https://www.npmjs.com/package/google-protobuf
Upvotes: 6
Reputation: 1814
You can install the module with npm:
npm install --save protobuf
Then require it this way:
var my_protobuff = require ("protobuf");
Upvotes: 0