Angular NGX Slider Won't Import and Materials Conflict

32 views Asked by At

I'm trying to add a range slider to my angular app using ngx-slider.

I followed the instructions from this guide and installed the newest version (angular and material are also up to date).

Up until now, my app.module.ts file looks like this:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';

//add other angular material modules () here
import { MatTableModule } from '@angular/material/table';
import { MatCardModule } from '@angular/material/card';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatButtonModule } from '@angular/material/button';
import { MatInputModule } from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSliderModule } from '@angular/material/slider';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TestComponent } from './components/test/test.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { FormsModule } from '@angular/forms'; // Add this line


@NgModule({
  declarations: [
    AppComponent,
    TestComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    MatTableModule,
    MatCardModule,
    MatSelectModule,
    MatProgressBarModule,
    MatButtonModule,
    MatInputModule,
    BrowserAnimationsModule,
    FormsModule,
    MatMenuModule,
    MatIconModule,
    MatSlideToggleModule, 
    MatSliderModule// Add this line
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

I use the material module in frontend components. Everything runs just fine. However, when importing ngx-slider into app.module.ts, I run into various errors:

  • I get the error NG8001 for almost all material modules, which are suddenly not known anymore

  • src/app/app.module.ts:24:33 - error TS2307: Cannot find module '@angular-slider/ngx-slider' or its corresponding type declarations. 24 import { NgxSliderModule } from '@angular-slider/ngx-slider'

  • Some more minor errors

The module is correctly installed and I can see it in the package.json file of the app, but not the package.json file of the frontend. I am a bit lost at what causes the seeming dependency error between the modules and why I can't load the module without error.

0

There are 0 answers