Firebase Client v9 (npm) experiencing issues with imports

Situation:

After finally taking the initiative to update the Firebase library in my app from 9.0.2 compat to the new modular, tree-shakable library, I encountered some issues. Using Windows 10 and WebStorm, my package.json only contains the dependency { "firebase": "^9.0.2" }.

Expected Outcome:

Following the documentation, when trying to import initializeApp:

import { initializeApp } from 'firebase/app';
const firebaseApp = initializeApp({ /* config */ });

I received an error stating Cannot resolve symbol 'initializeApp'.

Attempts at Resolution:

In a basic Vue.js project with ESLint and Babel, I attempted various fixes like deleting node_modules, clearing cache, and reinstalling npm packages, but the standard import still didn't work.

Current Solution:

Upon inspecting node_modules/firebase, I found all the standard functions within files like firebase-app.js and firebase-auth.js. This led me to import everything using:

import { initializeApp } from 'firebase/firebase-app';
const firebaseApp = initializeApp({ /* config */ });

However, this workaround doesn't seem normal or expected as no one else has reported it. What could be the issue here?

UPDATE: According to @Dharmaraj, this error is not present when using VS Code, indicating that it may be a WebStorm-specific problem.

Answer №1

It turns out that the issue was specific to WebStorm, as pointed out by @LazyOne. The solution for similar problems related to Cannot resolve symbol ... can be found here and here, applicable to both WebStorm and PhpStorm.

In summary: To resolve this issue, simply navigate to node_modules, right-click on the folder named @firebase, and choose Mark as not excluded.

By doing this, your IDE will index those files, allowing you to import functions from files within the @firebase directory since they are now recognized by the program.

A big thank you to everyone who contributed to solving this problem!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Assigning ng-view to "NAME" using RouteProvider

I'm completely new to Angular and I have a question regarding injecting a template or URL into multiple ng-views. However, my current approach involves having ng-view in my base template. My base template structure is as follows: <body> < ...

Using a Vue.js directive in a template

After studying the example at https://vuejs.org/examples/select2.html, I attempted to create a reusable component for future use. Regrettably, my code is not functioning as expected. Here is the HTML structure: <template id="my-template"> <p&g ...

Creating dynamic dropdown menus

I currently have a form that utilizes jQuery to perform the following tasks: Execute a series of ajax requests Modify select options dynamically based on the received data. I decided it would be interesting to try and recreate this functionality using vu ...

Using LinQ filter along with jQuery tmpl in a jQuery AJAX call illustration

After implementing this script to retrieve and filter a JSON dataset containing 100,000 elements for quick user-side searches, we have encountered performance issues. The script is not running fast enough. Do you have any suggestions on how to optimize th ...

I am seeking to perform these operations solely using pure WebGL, without relying on the Three.js library

if( keyboard.pressed("up")) pobjects[movementControls.translate].translateX(1); if( keyboard.pressed("down")) pobjects[movementControls.translate].translateX(-1); if( keyboard.pressed("left")) pobjects[mo ...

Tips for expanding AntD Table to show nested dataSource values

I need help dynamically rendering data into an antD expandable table. The data I have is a nested object with different properties - const values = [ [name = 'Josh', city = 'Sydney', pincode='10000'], [name = 'Mat ...

Tips for increasing the height of a popover when clicked

When a user focuses on the password input, a popover displays information. At the bottom of the popover, there is a link. How can I make the popover expand when the user clicks on this link? I have tried adding an !important class for the height value, us ...

Incorrect script enqueue order in child theme of WordPress

Help needed with enqueuing a script in a WordPress child theme. Despite specifying Jquery dependency, the script is loaded before Jquery. The code in question: add_action( 'wp_enqueue_scripts', 'child_theme_scripts' ); function child_ ...

I'm having issues with my Vue CDN code, as the output is displaying {{ name }} instead of the

I'm struggling with the Vue part of my code in both my brackets and Atom editors. I've tried multiple links, including the unpkg link, but nothing seems to work. Here is the code I've been working with: index.html: <!DOCTYPE html> ...

Storing an object in a model using MongoDB and Express

I have created a user schema in mongoose with various fields such as userName, firstName, lastName, password, rate, and rates. I am trying to perform a PUT request to store a new key/value pair in the rates object. Before updating the rates, I check if ...

Tapping on the invisible picture

I currently have a square image of a car with a transparent background. My goal is to make the car clickable so that when I click on it, it triggers an action. However, I also want the transparency around the car to allow clicks to go through and affect th ...

Trouble arises when using querySelectorAll with multiple identical ids

I'm having trouble fixing this issue. It's not affecting the HTML as I would like to. I am trying to dynamically add an href attribute via JavaScript to all a tags with the same id. Any suggestions? Thank you! <a id='mySrct' style=&a ...

Finding the destination URL after a redirect using JavaScript

<html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> function updateRedirectURL(){ var clientID = "hgffgh"; var clientSecret = "fgfhgfh"; ...

Utilizing aliases for CSS/SASS file imports with webpack

Can we use aliases to import .scss / .css files? // webpack.config.js resolve: { alias: { styles: path.resolve(__dirname, "src/styles/"), } } In the main.js file: // main.js import "styles/main.scss"; ...

How can I access a specific JSON object using its key?

Consider the object below: const ourObject = { "payload": { "streams": [ { "children": { "2165d20a-6276-468f-a02f-1abd65cad618": { & ...

Retrieve the top-level field from a Firestore document

I currently have a firestore database located at: https://i.sstatic.net/ebhXX.png My objective is to extract the value of the field "points/0/title" from its root. Is there any way to achieve this? ...

Form a collection of visible table rows without hidden columns

My table allows users to filter out specific rows by selecting a checkbox. When a checkbox is checked, certain rows are hidden. I am trying to create an array with all the rows that are not hidden, but I am having trouble accessing the visibility state of ...

Creating a specialized .toString() function for an array

When trying to create a custom .toString() method on the Array prototype, how can you access the actual array that the method is called on? This approach seems to work: Array.prototype.toString = () => 'custom'; "" + [1,2,3]; // 'custom ...

react-router is unable to navigate to the desired page

I am currently using react-router-dom in my project, but I am still relatively new to it. I have encountered an issue regarding page navigation. Below is the code for my App.js: class App extends Component { render() { return ( <div classN ...

Tips on searching for an entry in a database with TypeScript union types when the type is either a string or an array of strings

When calling the sendEmail method, emails can be sent to either a single user or multiple users (with the variable type string | string[]). I'm trying to find a more efficient and cleaner way to distinguish between the two in order to search for them ...