Solvedangularfire Firebase Storage is not working with ionic 3 & AngularFire 4.0.0 rc

**Angular:**Angular 4



import * as firebase from 'firebase';

const storageRef ='images/image.png');
storageRef.getDownloadURL().then(url => this.image = url);

error--> takes either no argument or a Firebase App instance

17 Answers

✔️Accepted Answer

Hey guys I was having this same problem, but getting an issue where it was saying that my Firebase app had not been initialized. After an hour of debugging, the solution was ending up being including auth and db in the constructor like so:

import { Component } from '@angular/core'
import { AngularFireAuth } from 'angularfire2/auth'
import { AngularFireDatabase } from 'angularfire2/database'
import * as firebase from 'firebase/app'
import 'firebase/storage'

  selector: 'page-photos',
  templateUrl: 'photos.html'
export class PhotosPage {
    public afAuth: AngularFireAuth,
    public afDb: AngularFireDatabase,
  ) {}

  upload() {
    const storageRef =
    // ...

So even though I don't use auth and db, I still had to include them in the constructor.

Other Answers:

in my case, I put both lines in a provider (not in Module) and then inject it to components that need access to the firebase storage, and no need to import { FirebaseApp } from 'angularfire2' anymore.

So in util-provider.ts:

import { AngularFireDatabase, FirebaseObjectObservable, FirebaseListObservable } from 
import * as firebase from 'firebase/app';
import 'firebase/storage';
//import { FirebaseApp } from 'angularfire2';

and then in the component:

import { UtilProvider } from '../../providers/util-provider';
constructor(public util: UtilProvider) {}

@markgoho I agree there are many response to this kind of issue. But after 120 google search and looking to issues finally found this one, which you referred to as
"Please search the issues before posting an error like this. It's been asked and answered a few times already."

but you are the only one who gave a simple and most clear answer. works. thanks.
But no question is a dumb question. the way information are presented may not be understood by everyone.

In your parent module, you should have import 'firebase/storage and in the component where you're using storage, you should have import { FirebaseApp } from 'angularfire2';

Please search the issues before posting an error like this. It's been asked and answered a few times already.

try this:
import * as firebase from 'firebase/app';
import 'firebase/storage';

Related Issues:

angularfire Missing exported members after updating to Angular 6.0.0
It looks like rxjs-compat is missing Use npm i rxjs-compat to install the missing rxjs-compat. ...
angularfire ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase
@jamesdaniels Yes npm install rxjs@6 rxjs-compat@6 --save It solved the issue. I want to use firebas...
angularfire @firebase/firestore: Firestore (5.8.0): timestampsInSnapshots
eg: app.module.ts Version info Angular: 7.2.1 Firebase: 5.8.0 AngularFire: 5.1.1 In the newest fireb...
angularfire 5.2.1 AngularFireAuthGuard causes TypeError: source.lift is not a function
I worked in this way Performing basic docs for AngularFireAuthGuard produces an error related to sou...
angularfire Just get the value once with no subscription
Use .take(1) which will kill the subscription once the first value has emitted. ...
angularfire [ERROR] Class 'FirebaseApp' incorrectly implements interface 'App'
Just to be super clear $ ionic cordova run browser Running app-scripts build: --platform browser --t...
angularfire Build error: This module is declared with using 'export ='
I see.. What happens when you add these entries to compilerOptions in tsconfig? ...
angularfire How to order by date?
Hey guys I just implemented a solution also to this using the mapping function this will return an O...
angularfire Namespace 'firebase' has no exported member 'Promise'.
Hey @dauledk! firebase.Promise was removed in version 4.5.0 of the firebase SDK Now you just use a r...
angularfire CollectionReference.doc function path should be optional
I agree this should align with the Firebase SDK A potential workaround is to use a pattern like this...
angularfire Cannot find namespace 'firebase'.
I am using angularfire2 in an ionic 2 project and I was getting the same error With the new angularf...
angularfire Firebase Storage is not working with ionic 3 & AngularFire 4.0.0 rc
Hey guys I was having this same problem but getting an issue where it was saying that my Firebase ap...
angularfire Calling AngularFireFunctions.httpsCallable results to error 404 because
The issue seems to come from #1920 (this file) resolving #1874 To get around it for now you can do t...
angularfire auth.login() Error "location.protocol" must be http or https
does it make sense to add some Help Wanted! or other label to raise the importance/severity? looks l...
angularfire Ducumentation Issues
@Anystrous Update: I see the problem The docs need this fix: We had breaking changes in version 5.0 ...
angularfire Cannot read property 'FacebookAuthProvider' of undefined - 2.0.0-beta.5
@arielcessario this works for me too as a workaround Hello Since I have updated my angularfire2 to t...
angularfire automaticDataCollectionEnabled' is missing in type 'FirebaseApp'
Same issue solved as suggested above.. At first Version info Angular: 5.2.9 Firebase: ^4.13.0 Angula...
angularfire Angular Ivy 9.0 stable and angularfire RC1 using Firestore have trouble with Universal
I am aiming to achieve success bundling us with Angular 9 SSR within a week Depending on the day of ...
angularfire Unhandled Promise rejection: this._next is not a function : Zone in @angular/fire/messaging
this worked for me: When I am receiving firebase push notifications in the foreground by using @angu...
angularfire Feature Request: Official version to delete a collection and all nested documents
There's no angularfire version You'd have to access the native Firestore SDK references: The above e...
angularfire FireStore timestampsInSnapshots
you can try but i dont know if it work : and comment: AngularFirestoreModule.enablePersistence() ...
angularfire Module '"/node_modules/angularfire2/angularfire2"' has no exported member 'AngularFireModule'.
@lfarroco @DMPS Can you try the pre-release version? I am trying to use the latest version of Angula...
angularfire How do I iterate through FirebaseListObservable<[]> object
Hi As this.users will get its data asynchronously from firebase you're likely trying to iterate befo...
angularfire AngularFire is not compatible with Firebase JS SDK v8
I still can't get auth and User by importing firebase/app It just says it doesn't have an exported m...
angularfire Can't run npm install angularfire2 firebase --save
I believe this issue is due to the latest version of firebase is now 4.0.0 but angularfire2@4.0.0-rc...
angularfire signInWithCredential error code auth/network-request-failed
Hi I have had the same problem with signInWithCredential which returns an error code auth/network-re...
angularfire Server Error. certificate has expired
I'm not super familiar with AngularFire but I'm pretty sure I found the issue ** Screenshots ** Expe...
angularfire Uncaught Error: "location.protocol" must be http or https when building to device using Ionic 2 & Angular 2
here is a project where I am running into issues -
components Error: mat-form-field must contain a MatFormFieldControl.
You have to add to app.module.ts: Bug feature request or proposal: When doing a karma/jasmine test I...
angular Angular5.x lazyLoad problem, undefined is not a function
For others that find this issue via Google as i did: I had the same problem when trying to lazy load...
angular Cyclic dependency error with HttpInterceptor
I resolved simply not setting authService in constructor but getting in the intercept function. ...
angular cli Issue: Cannot read property 'thisCompilation' of undefined
Here is the answer from issues #9793 : npm remove webpack npm install webpack@3.11.0 ...
angular Uncaught Error: Can't resolve all parameters for ...
You are missing an @Injectable() annotation on your ApiService Support requests like these should li...
ngx bootstrap fix(tooltip): tooltip flickering when hover the mouse on the border on the tooltip position
Add pointer-events: none; to the tooltip css problem solved! .tooltip { pointer-events: none; } ...
angular Force reload/refresh current route with RouteReuseStrategy
Hi If you really need to trick the Router into reloading the component on each routerLink click ...
angular Misleading error message "Cannot find a differ supporting object '[object Object]'"
I just ran into the same issue I'm not sure if the recommended solution will work for my case ...
angular cli Error | Could not find plugin "proposal-numeric-separator" | Generating ES5 bundles for differential loading
Try to install @babel/compat-data: ~7.8.0 to devDependencies This is the only workaround which helpe...
sheetjs How to simply export a Worksheet to xlsx?
There are two issues: each object is mapped to a row so if you want a row with name John and city Se...
angular cli Using invalid environment causes error in build (was "ERROR in Cannot read property 'length' of undefined")
Probably not the same cause but we had the same error (Cannot read property 'length' of undefined) w...
angular cli ng serve method ip not open in another machines
The solution is simple Just bind to the correct interface address via ng serve --host= ...
angular cli Incorrect JS paths when ng build -prod is deployed in a subfolder
When you're deploying to non-root path within a domain you'll need to manually update the <base href...
angular update 2 to 4 has problem [ts] Property 'map' does not exist on type 'Observable<Response>'.
I met the same problem with the angular cli 6.0.0 and rxjs 6.1.0 And I solved the problem by replaci...
angular cli Installation error: permission denied for node-sas
sudo npm install -g --unsafe-perm --verbose @angular/cli Installation error (node-sass) with: node v...
angular cli ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
Instead of use ng build --prod use ng build --env=prod UPDATE As many of us (thx) have mention this ...
storybook Webpack 4 support?
I'm getting the below error when running Storybook with a project using Webpack 4; This is preventin...
angular cli Property 'controls' does not exist on type 'AbstractControl'.
Got it! Looked at the docs - FormArray The FormArray class contains the controls property ...
angular Angular2 AoT Compiler Errors
pls try /cc @chuckjaz When I try to compile my project with ngc it throws the below error: Error: Er...
angular cli [Bug] cli needs to be reloaded when a lazy loaded module is added in routes (FIXED)
I recomended change { path: 'user-panel' loadChildren: './user-panel/user-panel.module#UserPanelModu...
prettier Change HTML/JSX formatting to have one attribute/prop per line
The point I am trying to make is that the vertical space matters Wasting it (too much) has negative ...
angular cli AOT build fails
I noticed same problem and after npm i enhanced-resolve@3.3.0 I can build with AOT ...