'Ngb-xx is not a known element

I am trying to use the ngb bootstrap on my Angular project. Every components on ngb throws me an error

enter image description here

My package.json

enter image description here

and my app.module.ts

enter image description here

Did I do something wrong? I followed and read the instructions carefully.



Solution 1:[1]

You have to import into the module you are using for the component , Bootstrap Module as it is mentioned in the docs

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  ...
  imports: [NgbModule, ...],
  ...
})
export class YourAppModule {
}

It works in this example https://stackblitz.com/edit/angular-d9uwjh?file=src%2Fapp%2Fdatepicker-basic.module.ts

Solution 2:[2]

Make sure the module is imported into your module in which the component going to use the Ngb-xx component. Means if you have a child component which uses Ngb component, include your Ngb module not in app module but if you are not using shared module, import it in the app module

With the latest version if Ngb-bootstrap, you need to only import the module which you want to use not the whole module like if you need accordian component, you can only import NgbAccordian module

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Aniruddha Das