Skip to content
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

Cannot import predefined google/protobuf/*.proto in node environment. #8339

Closed
ldshi opened this issue Oct 11, 2016 · 9 comments
Closed

Cannot import predefined google/protobuf/*.proto in node environment. #8339

ldshi opened this issue Oct 11, 2016 · 9 comments

Comments

@ldshi
Copy link

ldshi commented Oct 11, 2016

import "google/protobuf/empty.proto";
import "google/protobuf/any.proto";

will try to find the file with path: __dirname + google/protobuf/empty.proto, also tried to search the whole grpc node_module, cannot find the corresponding files.

what should I do?

@thinkerou
Copy link
Contributor

You should use the follow code?

import "src/proto/grpc/testing/empty.proto"

@ldshi
Copy link
Author

ldshi commented Oct 11, 2016

For the 'empty.proto' i can see the file is there, but for the 'any.proto' totally no that file.

And also in node environment with dynamic mode, no idea how to control the path.

@thinkerou
Copy link
Contributor

➜  grpc git:(master) pwd
/Users/thinkerou/Documents/opensource/grpc
➜  grpc git:(master) find . -name "any.proto"
./third_party/protobuf/src/google/protobuf/any.proto
➜  grpc git:(master)

@ldshi
Copy link
Author

ldshi commented Oct 11, 2016

In node environment, all modules supposed to be maintained by npm, so did u try to search int he node_module installed by 'npm install grpc'? i mentioned this very clearly in the issue description.

Apparently u should not download all the source then search there.

@dehypnosis
Copy link

dehypnosis commented Jan 16, 2017

same issue.. have any progress?

@HTChang
Copy link

HTChang commented Mar 1, 2017

@murgatroid99 @nathanielmanistaatgoogle so what is the best practice to include the predefined proto like empty?
the path we use is

 import "google/protobuf/empty.proto";

the proto was used for multiple language like go, java which is not just for JS.

@ikcro
Copy link

ikcro commented Jun 6, 2017

This question is not answered, many people have this doubt

@thedodd
Copy link

thedodd commented Sep 25, 2017

Would definitely be nice to see a resolution to this issue. Else, workaround seems to be: drop use of google/protobuf types, and implement your own types as somewhat close replacements.

In rust, golang and other languages where code generation is used for protobuf/grpc, this is not an issue.

@murgatroid99
Copy link
Member

We have now published the @grpc/proto-loader package, which allows for loading google/protobuf/*.proto files. If you have this problem, please try that package out.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants