-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: failed to import google/api/annotations.proto #433
Comments
Did you find a solution for this? I'm having the same issue when trying to create an GRPC server in node. |
It might be required to add google/api/annotations.proto and its dependencies to your application, if not bundled with grpc already. protobuf.js doesn't bundle it. |
Yep, that's what I did. |
If it's commented out, it works without error, but also it seems that there is a mechanism for handling missing but optional files (#368). So, basically, we can do this before a grpc parse: require('protobufjs').common('google/api/annotations.proto', {}) Since the annotation lib isn't needed by grpc (it parses the options directly.) |
But it looks like the version required by gRPC doesn't have
|
gRPC is still in the process of upgrading to protobuf.js v6. If no definitions from annotations.proto are used, actually, you could also just create an empty file at current working directory + |
would that work for nested structures, or just top-level proto files? I ended up doing this in with grpc: const getProto = (protoFile) => {
protobuf.common(`${path.dirname(protoFile)}/google/api/annotations.proto`, {})
return grpc.load(protoFile)
} Which works ok for single-level RPC service definitions, but I had to add a dependency for a newer version of protobuf to my project (to override grpc's) for it to work. |
Oh wait, that didn't actually work (I had it commented out, still.) Dummy file works for single-level rpc definitions and doesn't seem to break protoc stuff. |
If there was a concept of "include path" like protoc, I could be using my existing protoc include dir, which has this and also the common types. Maybe this is more of an issue for grpc. |
…tually referenced types within main files; Other: Added a few more common google types from google/api, see #433
It seems to be trying to import a local file called
google/api/annotations.proto
rather than enable optionsRelated issue: grpc-ecosystem/grpc-gateway#165
The text was updated successfully, but these errors were encountered: