Webpack fails to transpile CRA app, trying to import firebase from URL

Viewed 232

I've got a simple create-react-app going, have firebase (^9.1.1) npm package installed, and am trying to get up and running (this is my first go with Firebase - I have no idea what I'm doing...)

import { initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore';

const config = {
   ...
}

export const firestoreApp = initializeApp(config)
export const db = getFirestore(firestoreApp)
console.log(db.name)

When webpack works its magic, I get the following error

Failed to compile.

./node_modules/firebase/firebase-firestore.js
Module not found: Can't resolve 'https://www.gstatic.com/firebasejs/9.1.1/firebase-app.js' in '/Users/<user>/git/<project>/node_modules/firebase'

Looking at the file, the top has an import from a URL import { _registerComponent, registerVersion, _getProvider, getApp, _removeServiceInstance, SDK_VERSION } from 'https://www.gstatic.com/firebasejs/9.1.1/firebase-app.js';

Is this normal? I've never seen an import from a URL like this (but I'm also not a native JS dev) Is this a webpack issue and I'm just a dunce? A bug?

1 Answers

Yep, It's a bug. I had the same problem. Fixed it downgrading to the version before 9.1.1:

npm install firebase@9.1.0
Related