Closed aravinthkumarpk closed 3 weeks ago
Hi @aravinthkumarpk, thanks for reaching out to us. I was able to replicate the behavior that you've mentioned. I noticed that you're using the namedspace coding structure but importing the modular API. Here is a code snippet for importing the namespace API:
// compat packages are API compatible with namespaced code
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
You can also checkout this documentation about migrating to modular version of the SDK. I'll be closing this issue now. If you encounter another issue, feel free to create a new one.
Thanks for the super quick response. Appreciate it @jbalidiong. Put out a public appreciation post as well https://twitter.com/aravinthkumarpk/status/1788659691561603341 🙌
Also, there was a minor niggle in the suggestion. I am using real time database and hence had to use "import 'firebase/compat/database' instead of import 'firebase/compat/firestore'.
Operating System
mac OS Ventura 13.6.4
Browser Version
Chrome/124.0.6367.119
Firebase SDK Version
10.11.1
Firebase SDK Product:
Auth, Database
Describe your project's tooling
Describe the problem
Error: "SyntaxError: The requested module '/node_modules/.vite/deps/firebase_app.js?v=40e893b6' does not provide an export named 'default' (at firebase.js:2:8)"
Context: This error occurs when attempting to import Firebase into a React component, specifically in a file named firebase.js. The error indicates that the module path /node_modules/.vite/deps/firebase_app.js does not provide a default export as expected.
Steps and code to reproduce issue
Initialize Project: Create a new React project using Vite as the bundler.
Install Firebase: Install Firebase SDK for JavaScript using npm or yarn:
Configure Firebase: Create a
firebase.js
file to configure Firebase in the project. Example:Create Component Using Firebase: Create a component that uses Firebase, such as a signup form. Example:
Import Component: Import the
Signup
component into your main application file (App.js
or similar) and use it.Run Project: Start the development server using Vite and navigate to the signup page.
Expected Result
The signup form should render without any errors and should work correctly.
Actual Result
The following error is encountered: