grpc-node: Module 'http2' not found

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'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 21 (10 by maintainers)

Most upvoted comments

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

😦

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: https://github.com/facebook/create-react-app/pull/5686

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

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.

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