8

I am developing an Angular 2 app in which I want to use Protocol Buffers to send data to a Go server.

I found this dcodeIO/protobufjs. But I don't understand how should I use this in my project?

I also tried installing the typings for protobufjs using typings install dt~protobufjs --global. When I import it, WebStorm says Cannot find module protobuf.

Any help is appreciated!

1

1 Answer 1

14

I solved it! I did this npm install @types/protobufjs --save and I got the type definitions.

Then simply used it like this import * as ProtoBuf from 'protobufjs';

Thanks!

1
  • 1
    Thank you for this! And... If you are planning using pbjs and pbts utilities to convert your protos to JS and types install the packages globally (-g npm option). I wasted some time on this. Hope it helps someone.
    – AlexeiOst
    Commented Apr 4, 2019 at 15:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.