关于使用Stackblitz安装依赖项的问题

时间:2020-04-08 17:59:30

标签: angular npm node-modules stackblitz

我试图在我的stackblitz项目中安装ng-select,将其安装在依赖项部分中,并将导入内容插入app.module.ts https://stackblitz.com/edit/angular-ahhsfh?file=src%2Fapp%2Fapp.module.ts&cc=aa

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

import { AppComponent } from "./app.component";
import { HelloComponent } from "./hello.component";
import { HeaderComponent } from "./shared/header/header.component";
import { FooterComponent } from "./shared/footer/footer.component";
import { BookComponent } from "./components/book/book.component";
import { BookDetailComponent } from "./components/bookDetail/book.detail.component";
import { HttpClientModule } from "@angular/common/http";
import { FormComponent } from "./shared/form/form.component";
import { AppRoutingModule } from "./app-routing.module";
import { NgxPaginationModule } from "ngx-pagination";
import { Ng2SearchPipeModule } from "ng2-search-filter";
import { CommonModule } from "@angular/common";
import { NgSelectModule } from 'ng-select';



@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    AppRoutingModule,
    NgxPaginationModule,
    Ng2SearchPipeModule,
    CommonModule,
    NgSelectModule],

  declarations: [
    AppComponent,
    HelloComponent,
    HeaderComponent,
    FooterComponent,
    BookComponent,
    FormComponent,
    BookDetailComponent
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

但是我收到一个错误:

Error in src/app/app.module.ts (17:10)
Module '"../../../node_modules/ng-select/ng-select"' has no exported member 'NgSelectModule'. Did you mean 'SelectModule'?

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我认为您打算安装“ @ ng-select / ng-select”:https://www.npmjs.com/package/@ng-select/ng-select

“ ng-select”是一个似乎已被放弃的软件包:https://www.npmjs.com/package/ng-select

尝试安装“ @ ng-select / ng-select”,然后只需将app.module.ts中的import语句更改为:

import { NgSelectModule } from "@ng-select/ng-select";