Proto library to test how to publish a lib in npm
npm install @alexbrochu/proto-lib
let protobuf = require("protobufjs");
async function run() {
let root = await protobuf.load(
"node_modules/@alexbrochu/proto-lib/Protobuf lib/lib/constant.proto"
);
const Corpus = root.lookupEnum("awesomepackage.Corpus");
// console.log("Test ENUM", Corpus);
console.log("Corpus", Corpus.values.CORPUS_UNIVERSAL);
}
run().catch((err) => console.log(err));
This command will be link you node_modules package locally to your other project. Here I'm using @alexbrochu/proto-lib from my local environment
npm link @package/name
You have to login to npm before publishing
npm login
npm version [major-minor]
npm publish --access public # this will publish your package so it's available to everyone
To generate the proto pb source, you need to have this dependency install see
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc -I. -Ivendors --go_out=vendors lib/constant.proto