I've come across the need to import one file into another, but I can't find a clear explanation of how to do it.
So, I have my index proto file using some message from common.proto. All proto files lie in the same directory.
index.proto:
syntax = "proto3";
import "common.proto";
package index;
common.proto:
syntax = "proto3";
package common;
message Void {}
And I receive message: " Cannot resolve import 'common.proto' "
Have you already tried to set the --proto_path flag?
I tried it in my environment and what I think you are missing is telling Protobuf the location of your files
Here you can find the documentation: https://developers.google.com/protocol-buffers/docs/proto3#importing_definitions
includeDirsAn example :
app.connectMicroservice({
transport: Transport.GRPC,
options: {
package: 'sample.user',
protoPath: '/sample/user/user.proto',
loader: {
includeDirs: [join(__dirname, '..', 'protos')], // will load all proto files in the diectory 'protos'
},
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With