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

Module 'http2' not found #610

Closed
rakhi2104 opened this issue Nov 2, 2018 · 21 comments
Closed

Module 'http2' not found #610

rakhi2104 opened this issue Nov 2, 2018 · 21 comments

Comments

@rakhi2104
Copy link

Problem description

gRPC couldn't initialize due to the missing 'http2' module.

Reproduction steps

  • Use of package firebase-admin in React App, bootstrapped with create-react-app
  • Follow steps from Google Firebase Admin Documentation
  • Start the React App using yarn start or npm start

Environment

  • Linux Ubuntu 18.04 amd64
  • Node version 10.11.0
  • npm

Error message

Failed Compiling
./node_modules/@grpc/grpc-js/build/src/channel.js
Module not found: Can't resolve 'http2' in '/home/.../project1/node_modules/@grpc/grpc-js/build/src'
@nicolasnoble
Copy link
Member

How did you install the Node runtime?

@rakhi2104
Copy link
Author

Followed the standard installation guide here

@cjihrig
Copy link
Contributor

cjihrig commented Nov 2, 2018

What does node -p process.version and node -p http2 display? The http2 module is built into Node core, so if you're actually using version 10.11.0, then it should be there.

@rakhi2104
Copy link
Author

node -p process.version: outputs v10.11.0
node -p http2: outputs a list of constants.

@nicolasnoble
Copy link
Member

So, we'd need a more complete reproduction case. The http2 module seems to be working properly for you, so it failing like this doesn't make a lot of sense.

@kjin
Copy link
Contributor

kjin commented Nov 2, 2018

create-react-app seems to hardcode a list of Node built-in modules for which it creates empty mocks: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.dev.js#L451-L457

My guess is that this problem manifested because they haven't added http2 to the list yet.

Edit: facebook/create-react-app#5686

@murgatroid99
Copy link
Member

If you're using gRPC in a context where you need an empty http2 mock to load it, gRPC won't work because it fundamentally needs http2 to function.

@nicolasnoble
Copy link
Member

I'd also add that you can't make grpc work from the browser in any case. In other words, grpc can't be webpack-ed, therefore, you can't use it in a "react application" out of the box like this.

@kjin
Copy link
Contributor

kjin commented Nov 2, 2018

I'd imagine that grpc is only there as a dependency of firebase-admin rather than the app itself, and that webpack would compile but then prune it, so its inclusion would be inconsequential from the app developer's point of view. But now since the invocation of webpack in create-react-app doesn't know that http2 is a core module, it'll crash instead while compiling. (This is my guess)

@murgatroid99
Copy link
Member

If firebase-admin is not a necessary dependency of the app, then the correct solution is to omit it from the app, not to force it compile when you know that it won't function.

@kjin
Copy link
Contributor

kjin commented Nov 2, 2018

It seems like the module isn't supported on the client side: https://www.npmjs.com/package/firebase-admin#supported-environments

@christopher-johnson
Copy link

this issue is related to any library that depends on google-gax, so it is not specific to firebase-admin. For example, I am trying to use @google-cloud/vision. As noted, mocking http2 in webpack does not work. @google-cloud/vision is a client-side API, so it should work in the browser, no?

@christopher-johnson
Copy link

I guess that one way forward for browser support for google-gax is grpc-web?

@matiaslato
Copy link

:(

@IiroNiemi
Copy link

I had same issue, installed manually deprecated package of http2 to bypass that error with npm install http2.
I hope they add that module soon in create-react-app

@Wasi-Ayub
Copy link

IiroNiemi Thanks

@philval
Copy link

philval commented Sep 3, 2019

This happened after I installed the firebase deployment CLI today ( ? odd ). resolved by :

i) npm install http2
ii) npm uninstall firebase-admin ( personally can see how this is related, but was referred to in some stackoverflow answers )

@dmitry-yudakov
Copy link

dmitry-yudakov commented Sep 27, 2019

In my case the reason for "Module 'http2' not found" error was too old version of node - 8.4.x - set in package.json and used by heroku. It seems http2 was added by default in 8.8.0. Updating node version to 12.x.x and npm to 6.x.x solved the problem.

@iboxgithub
Copy link

I think @philval is correct the problem comes from firebase-admin. Looks very similar to that
googleapis/nodejs-dialogflow#314
Anyone found a way to use create-react-app with firebase-admin? To reproduce do:
npm install firebase admin
then in your code
var admin = require("firebase-admin");

@noahcoetsee
Copy link

Has this issue been resolved?

@murgatroid99
Copy link
Member

This "issue" is just that there are some environments where the @grpc/grpc-js library is not supported. The library is only intended to function on Node versions specified in the engines field in the package.json file.

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

No branches or pull requests