ES6 module cannot import firebase
See original GitHub issue[REQUIRED] Describe your environment
- Operating System version: MacOS 10.13.6
- Browser version: Chrome 83.0.4103.61
- Firebase UI version: 3.5.2
- Firebase SDK version: 7.14.0
[REQUIRED] Describe the problem
Steps to reproduce:
I am using import * as firebaseui from 'firebaseui'
to import firebaseui as an ES module (built with rollup) from node_modules/firebaseui/dist/esm.js
. This module tries to import firebase using import * as firebase from 'firebase/app'
from node_modules/firebase/app/dist/index.esm.js
, however this does not work an errors with auth is not exported by node_modules/firebase/app/dist/index.esm.js
. Instead it should be importing firebase with import firebase from 'firebase/app'
which works as expected.
Relevant Code:
https://stackblitz.com/fork/firebase-issue-sandbox
import firebase from "firebase/app";
import "firebase/auth";
var firebaseConfig = {
// ...
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
import * as firebaseui from "firebaseui";
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
How can I import firebase-database as an es6 module
2 Answers 2 ; import * as ; "firebase/app"; // If you enabled Analytics in your project, add the Firebase SDK for Analytics...
Read more >Alternative ways to add Firebase to your JavaScript project
You can configure partial import of the Firebase JavaScript SDK and only load the Firebase products that you need. Firebase stores each library ......
Read more >Directory import '[~]/node_modules/firebase/app' is not ...
When you applying Firebase into your Node.js project, You faces a bunch of errors. Here is the most common errors. .. is not...
Read more >How to deploy a firebase function packaged as ES6 module
import * as functions from "firebase-functions"; import myGreeting from ". ... Cannot find module '/functions/lib/my-greeting' imported from ...
Read more >Cannot use import statement outside module in JavaScript
The SyntaxError: Cannot use import statement outside a module occurs when we use the ES6 Modules syntax in a script that was not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also experienced this issue and used “string-replace-loader” to replace the
import * as firebase from 'firebase/app'
toimport firebase from 'firebase/app'
. This was inspired by an older issue in this project that I stumbled on.I’m using the latest preact-cli and I’m not sure this is a universal fix for other setups but this worked for me. Open source project for reference.
@bojeil-google this still seems like an active issue related to esm builds.
Running into the same issue I think. Using rollup resolve with a firebaseui import and get the same message as reported.
Per @maxwell8888’s note, @bojeil-google’s suggestion to use
import * as firebase...
causes other issues.Also tried @maxwell8888 's solution but ended up with a new issue…
and had to make the following change: