Priya
Priya

Reputation: 65

Object literal may only specify known properties, and 'entryComponents' does not exist in type 'NgModule'

After upgrading angular version from 11 to 17.3.8 it's throwing error line in my code wherever iused entry component in @NgModule. Becoz of this it's throwing error in all npm module while running it locally.

import { NgModule } from '@angular/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { CommonModule } from '@angular/common';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { ThemeModule } from '../../@theme/theme.module';
import { FormsModule } from '@angular/forms';
import { UsersComponent } from './users.component';
import { NbCardModule, NbButtonModule, NbSelectModule, NbInputModule, NbSpinnerModule } from '@nebular/theme';
import { AddUserComponent } from './add-user/add-user.component';
import { EditUserComponent } from './edit-user/edit-user.component';
import { DeleteUserComponent } from './delete-user/delete-user.component';

const COMPONENTS = [
  UsersComponent,
  AddUserComponent,
  EditUserComponent,
  DeleteUserComponent,
];

const ENTRY_COMPONENTS = [
  AddUserComponent,
  EditUserComponent,
  DeleteUserComponent,
];

const MODULES = [
  CommonModule,
  ThemeModule,
  NgbModule,
  NbButtonModule,
  NbSelectModule,
  NbInputModule,
  NbCardModule,
  Ng2SmartTableModule,
  FormsModule,
  NbSpinnerModule
];

@NgModule({
  imports: [...MODULES],
  declarations: [...COMPONENTS,],
  entryComponents: [...ENTRY_COMPONENTS]
})
export class UsersModule { }

Upvotes: 1

Views: 2840

Answers (1)

Naren Murali
Naren Murali

Reputation: 57986

entryComponents is no longer needed for higher versions of angular.

So remove the entryComponents from all your modules.

Move these components to the declarations array and it will work. If you get any errors that

Error: src/app/pages/web-filter/categories/categories.component.html:4:7 - error NG8001: 'nb-card-header' is not a known element:
1. If 'nb-card-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-card-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

4 <nb-card-header>

You have to import the respective modules/components into the module where you declared it, until there are no more errors.

Upvotes: 1

Related Questions