找不到模块'@ jf / consts / env-config.const'

时间:2020-02-23 20:53:59

标签: angular firebase environment

我这里有一个项目,是我从Github下载的,我想对其进行修改,但是在编写命令时出现错误代码:

<class 'list'>

错误代码:

app / app.module.ts:19:26中的错误-错误TS2307:找不到模块 '@ jf / consts / env-config.const'。 19从导入{ENV_CONFIG} '@ jf / consts / env-config.const';

代码:

$ ng serve

我试图创建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 {} 文件,但我不知道该文件应包含什么。 谁能帮我!

2 个答案:

答案 0 :(得分:1)

您是否使用与项目中相同的tsconfig文件?如果没有,请确保在tsconfig文件中使用定义相同的路径变量。

tstsconfig源文件:https://github.com/Jaspero/fireshop/blob/1d893923dd2c4016b4510b84dde7dfe60796306b/client/tsconfig.json

enter image description here

答案 1 :(得分:0)

问题已解决,我创建了一个名为env-config.ts的新文件,并添加了此文件:

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

现在对我有用。