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 namedgoogle-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
2 Answers
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
版权声明:本文标题:javascript - Error: Cannot find module 'google-protobuf' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744002399a2574098.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论