nodejs with protobuf
OS- Windows-10 64-bit
- Install Protoc
- Download ProtoBuf Compiler (protoc) protoc-3.8.0-win64.zip . - currently 3.8.0
- Unzip protoc to a location. Say C:/protobuf/protocWin
- Append Environment Variable PATH with C:/protobuf/protocWin/bin
- Get a .proto file (say, abc.proto). Place it in a directory. (E.g. C:/workingDir/)
- Compile the .proto file and generate import files (Closure Imports)
- Open command prompt/ powershell.
- Go to C:/workingDir/
- Type the following for creating separate import files for each message in the Proto file
protoc --js_out=,binary:./output abc.proto
- Or, for a single .js file
protoc --js_out=library=combined/lib,binary:./output abc.proto
- This will create lib.js in C:/workingDir/output/combined/
- Or, for Common Imports,
protoc --proto_path=src --js_out=import_style=commonjs,binary:combined/lib src/abc.proto
- Use these generated files as required. See the project structure.
-
Overview:
-
Javascript compilation:
-
NPM
-
Download