Error : R3InjectorError -> InjectionToken angularfire2.app.options

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options
</code>
<code>R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options </code>
R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options

Hi I’m building an Angular App and wanted to uitilize Firebase’s storage. I am running into an error when trying to inject AngularFireStorage inside my component. I am using Angular17 and firebase 10.11.0. Below is my code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>core.mjs:11809 ERROR NullInjectorError: R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]:
</code>
<code>core.mjs:11809 ERROR NullInjectorError: R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]: </code>
core.mjs:11809 ERROR NullInjectorError: R3InjectorError(Standalone[_ProfilePageComponent])[_AngularFireStorage -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]: 

NullInjectorError: No provider for InjectionToken angularfire2.app.options!

My app.config.ts file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideClientHydration } from '@angular/platform-browser';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideFirebaseApp } from '@angular/fire/app';
import { provideAuth } from '@angular/fire/auth';
import { provideFirestore } from '@angular/fire/firestore';
import { provideStorage } from '@angular/fire/storage';
import { provideHttpClient } from '@angular/common/http';
import { app, auth, storage } from './firebase.config';
import { getFirestore } from 'firebase/firestore';
import { HttpClientModule } from '@angular/common/http';
// `appConfig.ts` with providers for the Firebase app and services
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideClientHydration(),
provideHttpClient(),
provideAnimations(),
importProvidersFrom([
provideFirebaseApp(() => app),
provideAuth(() => auth),
provideFirestore(() => getFirestore(app)),
provideStorage(() => storage),
]),
],
};
</code>
<code>import { ApplicationConfig, importProvidersFrom } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; import { provideClientHydration } from '@angular/platform-browser'; import { provideAnimations } from '@angular/platform-browser/animations'; import { provideFirebaseApp } from '@angular/fire/app'; import { provideAuth } from '@angular/fire/auth'; import { provideFirestore } from '@angular/fire/firestore'; import { provideStorage } from '@angular/fire/storage'; import { provideHttpClient } from '@angular/common/http'; import { app, auth, storage } from './firebase.config'; import { getFirestore } from 'firebase/firestore'; import { HttpClientModule } from '@angular/common/http'; // `appConfig.ts` with providers for the Firebase app and services export const appConfig: ApplicationConfig = { providers: [ provideRouter(routes), provideClientHydration(), provideHttpClient(), provideAnimations(), importProvidersFrom([ provideFirebaseApp(() => app), provideAuth(() => auth), provideFirestore(() => getFirestore(app)), provideStorage(() => storage), ]), ], }; </code>
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideClientHydration } from '@angular/platform-browser';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideFirebaseApp } from '@angular/fire/app';
import { provideAuth } from '@angular/fire/auth';
import { provideFirestore } from '@angular/fire/firestore';
import { provideStorage } from '@angular/fire/storage';
import { provideHttpClient } from '@angular/common/http';
import { app, auth, storage } from './firebase.config';
import { getFirestore } from 'firebase/firestore';
import { HttpClientModule } from '@angular/common/http';

// `appConfig.ts` with providers for the Firebase app and services
export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideClientHydration(),
    provideHttpClient(),
    provideAnimations(),
    importProvidersFrom([
      provideFirebaseApp(() => app),
      provideAuth(() => auth),
      provideFirestore(() => getFirestore(app)),
      provideStorage(() => storage),
    ]),
  ],
};

My firebase.config.ts file. I X’d the config information.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { initializeApp } from 'firebase/app';
import { getAnalytics } from 'firebase/analytics';
import { getAuth } from 'firebase/auth';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/storage';
import { getStorage } from 'firebase/storage';
export const firebaseConfig = {
apiKey: 'X',
authDomain: 'X',
projectId: 'X',
storageBucket: 'X',
messagingSenderId: 'X',
appId: 'X',
measurementId: 'X',
};
export const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const storage = getStorage(app);
</code>
<code>import { initializeApp } from 'firebase/app'; import { getAnalytics } from 'firebase/analytics'; import { getAuth } from 'firebase/auth'; import 'firebase/auth'; import 'firebase/database'; import 'firebase/storage'; import { getStorage } from 'firebase/storage'; export const firebaseConfig = { apiKey: 'X', authDomain: 'X', projectId: 'X', storageBucket: 'X', messagingSenderId: 'X', appId: 'X', measurementId: 'X', }; export const app = initializeApp(firebaseConfig); export const auth = getAuth(app); export const storage = getStorage(app); </code>
import { initializeApp } from 'firebase/app';
import { getAnalytics } from 'firebase/analytics';
import { getAuth } from 'firebase/auth';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/storage';
import { getStorage } from 'firebase/storage';


export const firebaseConfig = {
  apiKey: 'X',
  authDomain: 'X',
  projectId: 'X',
  storageBucket: 'X',
  messagingSenderId: 'X',
  appId: 'X',
  measurementId: 'X',
};



export const app = initializeApp(firebaseConfig);

export const auth = getAuth(app);
export const storage = getStorage(app);

My component where I want to use Firebase Storage

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { AngularFireStorage } from '@angular/fire/compat/storage';
// import { AngularFireStorage } from '@angular/fire/storage';
// left out other parts of code that is irrelevant to this problem.
@Component({
selector: 'app-driver-profile',
standalone: true,
imports: [
CommonModule,
FormsModule,
],
templateUrl: './driver-profile.component.html',
styleUrl: './driver-profile.component.css',
})
export class DriverProfileComponent implements OnInit {
constructor(
private storage: AngularFireStorage,
private cdr: ChangeDetectorRef
) {}
</code>
<code>import { AngularFireStorage } from '@angular/fire/compat/storage'; // import { AngularFireStorage } from '@angular/fire/storage'; // left out other parts of code that is irrelevant to this problem. @Component({ selector: 'app-driver-profile', standalone: true, imports: [ CommonModule, FormsModule, ], templateUrl: './driver-profile.component.html', styleUrl: './driver-profile.component.css', }) export class DriverProfileComponent implements OnInit { constructor( private storage: AngularFireStorage, private cdr: ChangeDetectorRef ) {} </code>
import { AngularFireStorage } from '@angular/fire/compat/storage';
// import { AngularFireStorage } from '@angular/fire/storage';

// left out other parts of code that is irrelevant to this problem.

@Component({
  selector: 'app-driver-profile',
  standalone: true,
  imports: [
    CommonModule,
    FormsModule,
  ],

  templateUrl: './driver-profile.component.html',
  styleUrl: './driver-profile.component.css',
})
export class DriverProfileComponent implements OnInit {
  constructor(
    private storage: AngularFireStorage,
    private cdr: ChangeDetectorRef
  ) {}

Everytime i render this component, I get the exact same error to appear.

I’ve tried looking at other older forums post. Some of the posts said to use try injecting FirebaseStorage module, FirebaseModule, etc which didnt work.

I’ve tried changing import providers to the following below

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> importProvidersFrom([
provideFirebaseApp(() => initializeApp(environment.firebaseConfig)),
provideAuth(() => getAuth()),
provideFirestore(() => getFirestore()),
provideStorage(() => getStorage())
]),
</code>
<code> importProvidersFrom([ provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), provideAuth(() => getAuth()), provideFirestore(() => getFirestore()), provideStorage(() => getStorage()) ]), </code>
 importProvidersFrom([
      provideFirebaseApp(() => initializeApp(environment.firebaseConfig)),
      provideAuth(() => getAuth()),
      provideFirestore(() => getFirestore()),
      provideStorage(() => getStorage())
    ]),

and well as initializing the firebase app in my firebase.config.ts (what i have now)

I’ve tried importing AngularFireStorage from @angular/fire/storage, yet everytime i tried doing it I would get,
“angular/fire/storage” has no export named “AngularFireStorage.

so that led me to use {AngularFireStorage} from ‘@angular/fire/compat/storage’.

I was thinking once i was able to get the providers in my App.config.ts, that I would be able to use the storage in the component I want. I was able to get the Firebase authentication to work.

At this point, i’m really lost on what to do next. Any guidance would be greatly appreciated! Thank you in advance!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật