ng2-typeahead和browserify:意外的值' Typeahead'模块宣布' AppModule'

时间:2017-02-13 00:36:42

标签: angular

我已经打了好几天了。我尝试过这个解决方案,但并不完全适用:cannot find a module 'ng2-typeahead'。这是我的第一个项目,所以我可能会做些傻事。

我正在尝试浏览使用Typeahead的应用。当我在没有它的情况下运行它一切都很好,但不幸的是我的应用程序非常大,我需要削减它很多。当我这样做时,我收到一个错误,该应用程序无法正常工作。我已经对typeahead文档页面上的示例进行了一千次的复制和粘贴,以避免拼写错误,但它无法正常工作。下面是我的错误,低于我的小app.module.ts和system.config.js

13:22:43.808错误:(SystemJS)意外值' Typeahead'由模块宣布的AppModule'     [16] https://pluto.probono.net/scripts/related-content/app/bundle.js:18801:33     [16] https://pluto.probono.net/scripts/related-content/app/bundle.js:18788:19     [16] https://pluto.probono.net/scripts/related-content/app/bundle.js:21478:26     [16] compileModuleAndComponents @ https://pluto.probono.net/scripts/related-content/app/bundle.js:21416:34     [16] https://pluto.probono.net/scripts/related-content/app/bundle.js:21407:18     [17] bootstrapModuleWithZone @ https://pluto.probono.net/scripts/related-content/app/bundle.js:29098:20     [17] https://pluto.probono.net/scripts/related-content/app/bundle.js:29080:20     [9]< @ https://pluto.probono.net/scripts/related-content/app/bundle.js:1561:1     小号@ https://pluto.probono.net/scripts/related-content/app/bundle.js:1:639     È@ https://pluto.probono.net/scripts/related-content/app/bundle.js:1:818     @ https://pluto.probono.net/scripts/related-content/app/bundle.js:1:404     ZoneDelegate.prototype.invoke@https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:232:17     Zone.prototype.run@https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:114:24     scheduleResolveOrReject /< @ https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:502:52     ZoneDelegate.prototype.invokeTask@https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:265:21     Zone.prototype.runTask@https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:154:28     drainMicroTaskQueue @ https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:401:25     ZoneTask / this.invoke @ https://pluto.probono.net/scripts/related-content/node_modules/zone.js/dist/zone.js:339:25

APP.MODULE.TS:

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

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule }   from '@angular/forms';

import { ScheduleModule } from 'primeng/components/schedule/schedule';
import { CookieService } from 'angular2-cookie/services/cookies.service';

import { AppComponent } from './app.component';
import { EllipsisPipe } from './ellipsis.pipe';
import { ContentDisplayComponent } from './content-display.component';
import { ContentItemService } from './content-item.service';
import { Typeahead } from 'ng2-typeahead';
import { APP_BASE_HREF } from '@angular/common';

enableProdMode();

@NgModule({
imports: [ BrowserModule, HttpModule, ScheduleModule, FormsModule ],
providers: [ CookieService ],//, ActivatedRoute
declarations: [ AppComponent, ContentDisplayComponent, EllipsisPipe, 
    Typeahead ],
bootstrap: [ AppComponent ]
})

export class AppModule { }

SYSTEMJS.CONFIG.JS

(function (global) {
if(window.location.hostname === "localhost") {
basePath = "";
} else {
basePath = "/scripts/related-content/";
}
System.config({
paths: {
  // paths serve as alias
  'npm:': basePath + 'node_modules/',
  '': basePath
},
// map tells the System loader where to look for things
map: {
  // our app is within the app folder
  app: 'app',
  // angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
  'moment': 'npm:moment',
  'primeng': 'npm:primeng',
  'ng2-typeahead': 'npm:ng2-typeahead',
  'angular2-cookie': 'npm:angular2-cookie' 
},

packages: {
  app: {
    main: './bundle',/*main.min*/
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'angular-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'moment': { 
    main: 'moment.js',
    defaultExtension: 'js'
  },
  'primeng': { 
    main: "primeng",
    defaultExtension: 'js'
  },
  'angular2-cookie': { 
    main: "./core",
    defaultExtension: 'js'
  },
  'ng2-typeahead': { 
    main: 'ng2-typeahead.js', 
    defaultExtension: 'js' 
  }
  // 'ng2-typeahead': { 
  //   main: './index', 
  //   defaultExtension: 'js' 
  // }
}
});
})(this);

0 个答案:

没有答案