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

angular library component complains grpc is undefined during runtime when consumed by another angular project #1091

Open
neroarth94 opened this issue Mar 14, 2022 · 3 comments

Comments

@neroarth94
Copy link

I have an angular component that is made as a library and it has gRPC client codes in it. Everything works fine when I am testing the gRPC codes in the library itself.

But after I built the component as library, npm pack it and include it inside another angular project's node modules. It would have the below error complaining that the "grpc" module is null

import {grpc} from "@improbable-eng/grpc-web";

I have no idea what is causing the issue, is there anything that I need to import or add in the codes? I have make sure that the @improbable-eng/grpc-web module is indeed installed properly inside the node_modules folder

the package is installed with:
npm install google-protobuf @types/google-protobuf @improbable-eng/grpc-web --save

The error returned in the console is:
Uncaught TypeError: Cannot read properties of undefined (reading 'grpc') at Module.zUnb (main.10d8e8817d551e6f8d6e.js:1) at l (runtime.acf0dec4155e77772545.js:1) at Object.0 (main.10d8e8817d551e6f8d6e.js:1) at l (runtime.acf0dec4155e77772545.js:1) at t (runtime.acf0dec4155e77772545.js:1) at Array.r [as push] (runtime.acf0dec4155e77772545.js:1) at main.10d8e8817d551e6f8d6e.js:1

In the peerDependencies of the library component's package.json
"@improbable-eng/grpc-web": "0.15.0",
has been included too

@johanbrandhorst
Copy link
Contributor

This sounds like an environment problem, unfortunately this is really hard to debug without direct access to the environment, so you'll likely have to ask someone who knows more about your setup. Sorry we can't be of more help here, but there's unlikely to be a bug in the client since it works everywhere else.

@neroarth94
Copy link
Author

@johanbrandhorst is there any simple open source angular library component that uses grpc-web in it so that I can refer to?

@johanbrandhorst
Copy link
Contributor

I don't, no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants