如何在angular应用程序中添加模块而不会在控制台中出错?

如何在angular应用程序中添加模块而不会在控制台中出错?,angular,Angular,我在向我的应用程序添加新模块时遇到问题。我需要将ng2搜索过滤器添加到我的应用程序中,但我在控制台中遇到此错误,我的应用程序无法工作 我添加了所有应该添加的内容,下面是我的文件和文件结构。 注意:我正在.net web应用程序中创建angular应用程序,并通过package.json添加新模块 app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platf

我在向我的应用程序添加新模块时遇到问题。我需要将ng2搜索过滤器添加到我的应用程序中,但我在控制台中遇到此错误,我的应用程序无法工作

我添加了所有应该添加的内容,下面是我的文件和文件结构。 注意:我正在.net web应用程序中创建angular应用程序,并通过package.json添加新模块

app.module.ts

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

import { APP_BASE_HREF } from '@angular/common';
import { routing } from './app.routing';

import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

import { LoginService } from './service/login.service';
import { SearchUserComponent } from './search-user/search-user.component';

import { RegisterComponent } from './register/register.component';
import { RegisterService } from './service/register.service';
import { CategoryManagementService } from './service/category-management';
import { LanguageManagementService } from './service/language-management';

import { SearchBooksService } from './service/search-books.service';
import { SearchBooksComponent } from './search-books/search-books.component';

import { Ng2SearchPipeModule } from "ng2-search-filter";


@NgModule({
    imports: [BrowserModule, HttpModule, FormsModule, routing, Ng2SearchPipeModule],
    declarations: [AppComponent, RegisterComponent, LoginComponent, SearchUserComponent, SearchBooksComponent],
    providers: [{ provide: APP_BASE_HREF, useValue: '/' }, RegisterService, LoginService, LanguageManagementService, CategoryManagementService, SearchBooksService],
    bootstrap: [AppComponent]
})
export class AppModule { }
systemjs.config.js

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // 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/bundles/in-memory-web-api.umd.js',
      'ng2-search-filter': 'node_modules/ng2-search-filter'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        main:'main.js'

      },
      rxjs: {
        defaultExtension: 'js'
        },

      'ng2-search-filter': { main: 'dist/index.js' }
    }
  });
})(this);


更新package.json后,您是否运行了
npm安装
?您的
ng2搜索过滤器
文件夹中没有
dist
文件夹。很可能是
软件包安装不正确。谢谢大家,我现在将删除node_模块并重新安装模块,看看问题是否仍然存在。@我不是这样安装软件包的,我正在我的package.json中插入版本,然后右键单击并还原包。@IftifarTaz我删除了node_模块并再次安装了所有模块,但它不起作用。下一步怎么办?更新package.json后,您是否运行了
npm安装
?您的
ng2搜索过滤器
文件夹中没有
dist
文件夹。很可能是
软件包安装不正确。谢谢大家,我现在将删除node_模块并重新安装模块,看看问题是否仍然存在。@我不是这样安装软件包的,我正在我的package.json中插入版本,然后右键单击并还原包。@IftifarTaz我删除了node_模块并再次安装了所有模块,但它不起作用。下一步怎么办?