加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

角度 – 错误:模块导入的意外值“未定义”

发布时间:2020-12-17 07:42:20 所属栏目:安全 来源:网络整理
导读:迁移到NgModule之后,我收到这个错误,这个错误没有帮助太多,有什么建议吗? Error: Error: Unexpected value 'undefined' imported by the module 'AppModule' at new BaseException (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler
迁移到NgModule之后,我收到这个错误,这个错误没有帮助太多,有什么建议吗?
Error: Error: Unexpected value 'undefined' imported by the module 'AppModule'
        at new BaseException (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:5116:27)
        at eval (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13231:35)
        at Array.forEach (native)
        at CompileMetadataResolver.getNgModuleMetadata (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13215:48)
        at RuntimeCompiler._compileComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15845:51)
        at RuntimeCompiler._compileModuleAndComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15769:41)
        at RuntimeCompiler.compileModuleAsync (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15746:25)
        at PlatformRef_._bootstrapModuleWithZone (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9991:29)
        at PlatformRef_.bootstrapModule (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9984:25)
        at Object.eval (http://localhost:5555/app/main.js:8:53)
    Evaluating http://localhost:5555/app/main.js
    Error loading http://localhost:5555/app/main.js "Report this error at https://github.com/mgechev/angular2-seed/issues"(anonymous function) @ contracts:142ZoneDelegate.invoke @ zone.js?1472711930202:332Zone.run @ zone.js?1472711930202:225(anonymous function) @ zone.js?1472711930202:586ZoneDelegate.invokeTask @ zone.js?1472711930202:365Zone.runTask @ zone.js?1472711930202:265drainMicroTaskQueue @ zone.js?1472711930202:491ZoneTask.invoke @ zone.js?1472711930202:435

app.module.ts:

import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { APP_BASE_HREF } from '@angular/common';
    import { RouterModule } from '@angular/router';
    import { HttpModule } from '@angular/http';
    import { AppComponent } from './app.component';
    import { routes } from './app.routes';

    import { provide } from '@angular/core';

    //dgf ng2-translate
    import { TRANSLATE_PROVIDERS,TranslateLoader,TranslateStaticLoader,MissingTranslationHandler } from 'ng2-translate/ng2-translate';
    import { HTTP_PROVIDERS,Http } from '@angular/http';
    import { FormsModule,ReactiveFormsModule } from '@angular/forms';
    import { TranslationNotFoundHandler } from './shared/common/TranslationNotFoundHandler';
    //dgf ng2-translate END

    import {CalendarModule,DataTableModule,DialogModule,PanelModule} from 'primeng/primeng';

    import {TranslateModule} from 'ng2-translate/ng2-translate';

    import { AuthGuard,AppConfigService,AppConfig,DateHelper,ThemeComponent,ToolbarComponent,RemoveHostTagDirective } from './index';
    import { HomeComponent,MessagesExampleComponent,PrimeNgHomeComponent,CalendarComponent,Ng2BootstrapExamplesComponent,DatepickerDemoComponent,UserListComponent,UserEditComponent,ContractListComponent,AboutComponent } from './index';


@NgModule({
  imports: [BrowserModule,HttpModule,RouterModule.forRoot(routes),/* AboutModule,HomeModule,SharedModule.forRoot()*/
          FormsModule,ReactiveFormsModule,//third-party,TranslateModule.forRoot() //,//third-party PRIMENG,CalendarModule,PanelModule
  ],declarations: [
    AppComponent,RemoveHostTagDirective,HomeComponent,AboutComponent
  ],providers: [{
      provide: APP_BASE_HREF,useValue: '<%= APP_BASE %>'
    },FormsModule,provide(TranslateLoader,{ //DGF ng2-translate
          useFactory: (http: Http) => new TranslateStaticLoader(http,'assets/i18n','.json'),deps: [Http]
      }),provide(MissingTranslationHandler,{ useClass: TranslationNotFoundHandler }),//DGF ng2-translate

    AuthGuard,DateHelper
  ],bootstrap: [AppComponent]
})

export class AppModule { }
对于面临同样错误的人来说,我的情况是在导入部分有双逗号
imports: [
      BrowserModule,RouterModule.forRoot(appRoutes),// <-- this was the error
      // .... 
],

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读