ngx-bootstrap: Cannot read property 'forRoot' of undefined on Angular-CLI project
Bug on Angular-CLI project
Build using ng serve or ng build: OK
Console Error:
app.module.ts Uncaught TypeError: Cannot read property ‘forRoot’ of undefined at app.module.ts
The only other module I import is ToastModule. I tested without it and the error still occurs.
Versions
ng --version angular-cli: 1.0.0-beta.24 node: 7.2.1 os: win32 x64 @angular/common: 2.4.5 @angular/compiler: 2.4.5 @angular/core: 2.4.5 @angular/forms: 2.4.5 @angular/http: 2.4.5 @angular/platform-browser: 2.4.5 @angular/platform-browser-dynamic: 2.4.5 @angular/router: 3.4.5 @angular/compiler-cli: 2.4.5
Steps
Install both ng2-bootstrap and bootstrap:
npm install --save ng2-bootstrap bootstrap
app.module.ts
...
import { ToastModule } from 'ng2-toastr/ng2-toastr';
import { AlertModule } from 'ng2-bootstrap';
...
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
ToastModule,
AlertModule.forRoot(),
// Routing
RouterModule.forRoot(ROUTES, { useHash: false, preloadingStrategy: PreloadAllModules })
],
providers: [ ],
bootstrap: [AppComponent]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 16 (5 by maintainers)
Solved an old version
npm install ng2-bootstrap@1.2.6 --saveThanks LeGonidec. +1