Amin Alhossein
Amin Alhossein

Reputation: 53

Cannot find module '@jf/consts/env-config.const'

I have a project here that I downloaded from Github, I want to modify it but I get the error code when I write the command:

$ ng serve

Error code:

ERROR in app/app.module.ts:19:26 - error TS2307: Cannot find module '@jf/consts/env-config.const'. 19 import {ENV_CONFIG} from '@jf/consts/env-config.const';

code:

import {APP_INITIALIZER, Injector, NgModule} from '@angular/core';
import {AngularFireModule} from '@angular/fire';
import {AngularFirestore, AngularFirestoreModule} from '@angular/fire/firestore';
import {AngularFirePerformanceModule} from '@angular/fire/performance';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ENV_CONFIG} from '@jf/consts/env-config.const';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {LayoutComponent} from './shared/components/layout/layout.component';
import {appInit} from './shared/helpers/app-init';
import {FileUploadModule} from './shared/modules/file-upload/file-upload.module';
import {SharedModule} from './shared/shared.module';

export function init(injector: Injector) {
  return () => {
    return appInit(injector.get(AngularFirestore));
  };
}

@NgModule({
  declarations: [AppComponent, LayoutComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    SharedModule,
    BrowserAnimationsModule,

    FileUploadModule.forRoot(),

    /**
     * External
     */
    AngularFireModule.initializeApp(ENV_CONFIG.firebase),
    AngularFirestoreModule.enablePersistence(),
    AngularFirePerformanceModule
  ],
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: init,
      deps: [Injector],
      multi: true
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

I tried to create the {ENV_CONFIG} file , I don't know what this file should contain. Can anyone help me!

Upvotes: 0

Views: 115

Answers (2)

Amin Alhossein
Amin Alhossein

Reputation: 53

The problem has been resolved I created a new file called: env-config.ts And i added this :

export const ENV_CONFIG = {
  production: false,
  firebase: {
    apiKey: '',
    authDomain: '',
    databaseURL: '',
    projectId: '',
    storageBucket: '',
    appId: '',
    measurementId: ''
  },
  stripe: {
      token: ''
  }
};

This works for me now.

Upvotes: 0

Dipen Shah
Dipen Shah

Reputation: 26075

Are you using same tsconfig file as in the project? If not make sure to use define same path variable in your tsconfig file.

Source tsconfig file: https://github.com/Jaspero/fireshop/blob/1d893923dd2c4016b4510b84dde7dfe60796306b/client/tsconfig.json

enter image description here

Upvotes: 1

Related Questions