When attempting to access Firebase Storage with Angular, you may encounter the error message: "TypeError: app.storage

Having trouble connecting my Angular app to FireBase. The component appears blank and the Chrome console is showing a 'TypeError: app.storage is not a function'. Any ideas on what I might be doing wrong? Thanks in advance.

ng --version

Angular CLI: 13.3.11
Node: 16.15.0
Package Manager: npm 8.5.5
OS: win32 x64

Angular: 13.3.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.11
@angular-devkit/build-angular   13.3.11
@angular-devkit/core            13.3.11
@angular-devkit/schematics      13.3.11
@angular/cdk                    13.3.9
@angular/cli                    13.3.11
@angular/fire                   7.6.1
@angular/material               13.3.9
@schematics/angular             13.3.11
rxjs                            7.5.7
typescript                      4.6.4

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AngularFireModule } from '@angular/fire/compat';
import { AngularFireAuthModule } from '@angular/fire/compat/auth';
import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
import { AngularFireStorageModule } from '@angular/fire/compat/storage';
import { AngularFireDatabaseModule } from '@angular/fire/compat/database'

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { Page404Component } from './page404/page404.component';
import { environment } from 'src/environments/environment';
import { UploadComponent } from './upload/upload.component';


@NgModule({
  declarations: [
    AppComponent,
    Page404Component,
    UploadComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,
    AngularFireStorageModule,
    AngularFirestoreModule,
    AngularFireDatabaseModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app-routing.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes, PreloadAllModules } from '@angular/router';
import { Page404Component } from './page404/page404.component';
import { AuthGuard } from '@auth/guards/auth.guard';
import { UploadComponent } from './upload/upload.component';

const routes: Routes = [
//routes go here
];

@NgModule({
  imports: [RouterModule.forRoot(routes,{
    preloadingStrategy: PreloadAllModules})],
  exports: [RouterModule]
})
export class AppRoutingModule { }

...and the test component...

upload.component.ts

//Upload Component TypeScript Code here

upload.component.html

<p>upload works!</p>

full error on chrome console

Error: Uncaught (in promise): TypeError: app.storage is not a function
TypeError: app.storage is not a function
//Error details...

Answer №1

Encountered the same error while setting up AngularFireStorage. Resolved it by reverting firebase back to version 9 as the latest version 10 is not yet compatible with @angular/fire 7.x. More details can be found here: https://github.com/angular/angularfire/tree/master#angular-and-firebase-versions

To ensure a clean reset, I removed my nodes_modules directory and reinstalled:

npm install
npm i --save <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="51373823343330223411687f63627f61">[email protected]</a>
ng add @angular/fire

After following these steps, the issue was resolved in my project.

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

return to the previous mat tab by using the browser's back button

Currently working on an Angular project, I am faced with the challenge of configuring the Mat Tab to close the active tab and return to the previously accessed tab when the browser's back button is clicked. How can I accomplish this without relying on ...

What is the best way to simulate an overloaded method in jest?

When working with the jsonwebtoken library to verify tokens in my module, I encountered a situation where the verify method is exported multiple times with different signatures. export function verify(token: string, secretOrPublicKey: Secret, options?: Ve ...

Tips for resolving the AngularFire migration error related to observables

Recently, I decided to upgrade a project that had been untouched for over a year. Originally built on Angular 10, I made the jump to Angular 12. However, the next step was upgrading AngularFire from v6 to v7, and it appears there is an issue with typings. ...

What is the process for implementing a pipe to establish data binding?

I've been trying to use a pipe for data binding in Angular, but it's not working as expected. Previously, I had this: [message]="enum.text" and now I want to replace enum.text with a custom pipe. Here's what I tried: [text]=" '' ...

Sending a Nan alert regarding a JSON attribute

I recently completed a project using Angular4 that involves connecting to a nodeExpressJS server to retrieve JSON data and update the object with new information. Below is the onSubmit function from the addemployeeform. onSubmit(formValue: any) { cons ...

Issue with handling http errors and navigating routes in Angular 2

Whenever I check a user's token authentication and encounter a 401 error, I aim to redirect them to the login page. The issue arises when attempting to navigate to the login page within the error catch block. constructor(private http: Http , private ...

Here is a unique version of the text: "Utilizing Various MAT_DATE_FORMATS

I am facing an issue with multiple date input formats in a component. While most inputs follow the standard MM/DD/YYYY format, one requires a custom format (MM/YYYY). I found guidance here on how to customize the format but now all inputs are displaying wi ...

The issue with ng-select arises when the placeholder option is selected, as it incorrectly sends "NULL" instead of an empty string

When searching for inventory, users have the option to refine their search using various criteria. If a user does not select any options, ng-select interprets this as "NULL," which causes an issue because the server expects an empty string in the GET reque ...

Awaitable HttpResponseError

My challenge is that I'm attempting to handle a HttpError or HttpErrorResponse using an observable. However, the only option I have is to handle the HttpResponse, which is necessary but not sufficient. I also need to find a way to avoid this limitatio ...

The hidden pop-up window from a particular tool is currently not being displayed

I attempted to upload my code onto Stackblitz in search of assistance with my dynamic modal not displaying. I am working on a function that I intend to be able to call from any component to create a popup where I can dynamically modify the header, body, an ...

Conceal the Header on the Login Module

Within my app.component, I have a header and body component. <app-header></app-header> <div class="body"> <router-outlet></router-outlet> </div> I am looking to hide the header element when in the login co ...

Converting an HTML page to PDF with Angular using jsPdf and Html2Canvas

[1st img of pdf generated with position -182, 0, image 208,298 ][1]Converting an HTML page to PDF in Angular 8+ using jspdf and Html2canvas has been a challenge. Only half of the page is successfully converted into PDF due to a scaling issue. Printing th ...

Code error TS2345 occurs when assigning the argument of type '{ headers: HttpHeaders; }' to a parameter of type 'RequestOptionsArgs'. This indicates a mismatch in the type of data being passed, causing an

Upon running ionic serve, these are the results that I am encountering. My setup consists of Ionic4 version with Angular 8. While executing the command, this error appears: src/app/home/home.page.ts:60:77 - error TS2345: Argument of type '{ headers ...

Tips on transforming Angular 2/4 Reactive Forms custom validation Promise code into Observable design?

After a delay of 1500ms, this snippet for custom validation in reactive forms adds emailIsTaken: true to the errors object of the emailAddress formControl when the user inputs [email protected]. https://i.stack.imgur.com/4oZ6w.png takenEmailAddress( ...

What is the best way to reset an imported file with each test in viTest?

I'm having trouble resetting an imported file completely after each test. I believe that using vi.mock should mimic the original contents of my imported file, but it doesn't seem to be working when I try to modify the file during the tests. Here ...

Steps for launching a stackblitz project

Apologies for the novice question. As a beginner in Angular (and StackBlitz), I have created a StackBlitz project to seek assistance on an Angular topic (reactive forms). However, I am unable to run it. Can anyone guide me on how to do so? Thank you. ...

Remove validators from an Angular formArray

Is there a way to reset validators for the formArray within my formGroup? Check out my StackBlitz for reference. .ts this.createEstimation = this.fb.group({ name: ['', Validators.required], surname: ['', Validators.required], ca ...

Troubleshooting: Issues with APIGateway's Default Integration

I'm currently utilizing the AWS CDK to construct my API Gateway REST API My objective is to have my RestApi configured to automatically return an HTTP 404 error, so I set it up as follows: this.gateway = new apigw.RestApi(this, "Gateway", { ...

Comparing the use of Angular with Node.js and Nginx

Simply a question on my mind. In terms of benefits, which would be more advantageous: running my angular application through node with nginx as a reverse proxy or serving it directly from nginx? My intuition tells me that direct server from nginx would r ...

Error TS2322: Type 'boolean' cannot be assigned to type 'undefined'. What is the best approach for dynamically assigning optional properties?

I am currently working on defining an interface named ParsedArguments to assign properties to an object, and here is what it looks like: import {Rules} from "../Rules/types/Rules"; export interface ParsedArguments { //other props //... ...