admin管理员组

文章数量:1356950

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._pile (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

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._pile (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

Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Mar 23, 2016 at 8:50 ItayBItayB 11.4k11 gold badges60 silver badges93 bronze badges 4
  • npm does not list any module named google-protobuf. Probably it has been moved, renamed or is published elsewhere. – s.d Commented Mar 23, 2016 at 9:05
  • @S.D there is npmjs./package/protobuf This is a fork of code.google./p/protobuf-for-node – Luke Commented Mar 23, 2016 at 9:17
  • There is a require statement at line 8 of ServiceMessage_pb.js that specifically requires google-protobuf. It looks like the generator of this file uses google-protobuf, while actual module is protobuf. – s.d Commented Mar 25, 2016 at 8:26
  • npm homepage of the National Association of Pastoral Musicians, true, no protos there. – conjectures Commented Dec 7, 2023 at 21:21
Add a ment  | 

2 Answers 2

Reset to default 6
    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./package/google-protobuf

You can install the module with npm:

npm install --save protobuf

Then require it this way:

var my_protobuff = require ("protobuf");

本文标签: javascriptError Cannot find module 39googleprotobuf39Stack Overflow