简体   繁体   中英

Module Not Found: Can't resolve 'http2' when importing firebase-admin

        Failed to compile
    ./node_modules/@grpc/grpc-js/build/src/channel.js
    Module not found: Can't resolve 'http2' in '/Users/Michael/Development/Projects/mpsa-ntcs/node_modules/@grpc/grpc-js/build/src'

This error occurred during the build time and cannot be dismissed.

I keep getting this error when importing firebase-admin to my app. I tried updating GRPC, tried downgrading/upgrading node, reinstalled node + npm... everything!!

Anyone know any workarounds for this?

Thanks!

I believe you need to install the deprecated 'http2' package. Try running:

npm install http2

I have changed to use yarn. Remove yarn remove firebase-admin Install again yarn add firebase yarn add firebase-admin yarn add http2 And my code can work. I think yarn is better than npm.

Note: http is supported from node version 9.0.0. My Node version is 13.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM