【问题标题】:Problem on installing dependencies with Stackblitz使用 Stackblitz 安装依赖项的问题
【发布时间】:2020-07-21 05:46:13
【问题描述】:

我尝试在我的 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'?

我该如何解决?

【问题讨论】:

    标签: angular npm node-modules stackblitz


    【解决方案1】:

    我认为您的意思是安装“@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 { NgSelectModule } from "@ng-select/ng-select";
    

    【讨论】:

      猜你喜欢
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-29
      • 2017-12-23
      • 1970-01-01
      • 2019-04-29
      • 2023-04-03
      相关资源
      最近更新 更多