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

前端之家收集整理的这篇文章主要介绍了角度 – 错误:模块导入的意外值“未定义”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
迁移到NgModule之后,我收到这个错误,这个错误没有帮助太多,有什么建议吗?
  1. Error: Error: Unexpected value 'undefined' imported by the module 'AppModule'
  2. at new BaseException (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:5116:27)
  3. at eval (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13231:35)
  4. at Array.forEach (native)
  5. at CompileMetadataResolver.getNgModuleMetadata (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:13215:48)
  6. at RuntimeCompiler._compileComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15845:51)
  7. at RuntimeCompiler._compileModuleAndComponents (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15769:41)
  8. at RuntimeCompiler.compileModuleAsync (http://localhost:5555/node_modules/@angular/compiler/bundles/compiler.umd.js:15746:25)
  9. at PlatformRef_._bootstrapModuleWithZone (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9991:29)
  10. at PlatformRef_.bootstrapModule (http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:9984:25)
  11. at Object.eval (http://localhost:5555/app/main.js:8:53)
  12. Evaluating http://localhost:5555/app/main.js
  13. 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:

  1. import { NgModule } from '@angular/core';
  2. import { BrowserModule } from '@angular/platform-browser';
  3. import { APP_BASE_HREF } from '@angular/common';
  4. import { RouterModule } from '@angular/router';
  5. import { HttpModule } from '@angular/http';
  6. import { AppComponent } from './app.component';
  7. import { routes } from './app.routes';
  8.  
  9. import { provide } from '@angular/core';
  10.  
  11. //dgf ng2-translate
  12. import { TRANSLATE_PROVIDERS,TranslateLoader,TranslateStaticLoader,MissingTranslationHandler } from 'ng2-translate/ng2-translate';
  13. import { HTTP_PROVIDERS,Http } from '@angular/http';
  14. import { FormsModule,ReactiveFormsModule } from '@angular/forms';
  15. import { TranslationNotFoundHandler } from './shared/common/TranslationNotFoundHandler';
  16. //dgf ng2-translate END
  17.  
  18. import {CalendarModule,DataTableModule,DialogModule,PanelModule} from 'primeng/primeng';
  19.  
  20. import {TranslateModule} from 'ng2-translate/ng2-translate';
  21.  
  22. import { AuthGuard,AppConfigService,AppConfig,DateHelper,ThemeComponent,ToolbarComponent,RemoveHostTagDirective } from './index';
  23. import { HomeComponent,MessagesExampleComponent,PrimeNgHomeComponent,CalendarComponent,Ng2BootstrapExamplesComponent,DatepickerDemoComponent,UserListComponent,UserEditComponent,ContractListComponent,AboutComponent } from './index';
  24.  
  25.  
  26. @NgModule({
  27. imports: [BrowserModule,HttpModule,RouterModule.forRoot(routes),/* AboutModule,HomeModule,SharedModule.forRoot()*/
  28. FormsModule,ReactiveFormsModule,//third-party,TranslateModule.forRoot() //,//third-party PRIMENG,CalendarModule,PanelModule
  29. ],declarations: [
  30. AppComponent,RemoveHostTagDirective,HomeComponent,AboutComponent
  31. ],providers: [{
  32. provide: APP_BASE_HREF,useValue: '<%= APP_BASE %>'
  33. },FormsModule,provide(TranslateLoader,{ //DGF ng2-translate
  34. useFactory: (http: Http) => new TranslateStaticLoader(http,'assets/i18n','.json'),deps: [Http]
  35. }),provide(MissingTranslationHandler,{ useClass: TranslationNotFoundHandler }),//DGF ng2-translate
  36.  
  37. AuthGuard,DateHelper
  38. ],bootstrap: [AppComponent]
  39. })
  40.  
  41. export class AppModule { }
对于面临同样错误的人来说,我的情况是在导入部分有双逗号
  1. imports: [
  2. BrowserModule,RouterModule.forRoot(appRoutes),// <-- this was the error
  3. // ....
  4. ],

猜你在找的Angularjs相关文章