Home > Blockchain >  How to import proto file in another proto file in NestJS
How to import proto file in another proto file in NestJS

Time:04-20

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' "

CodePudding user response:

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

  • Related