Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

521
Vistas
Using Angular Library component in local project - not working

I have created a angular workspace that contains my project and library. Below is the project structure:

FOLDER STRUCTURE

I have build my library -(This uses form module)

ng build demo-lib

and it compiles successfully and creates a folder inside dist folder.

Now I have imported the module inside app.module.ts and added under import:

import { DemoFormComponent, DemoLibModule } from 'demo-lib'
.
.
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    DemoLibModule,
    DemoFormComponent
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

But when I serve my application I get below error, I am not sure what I am doing wrong :-

Error: dist/demo-lib/lib/demo-form/demo-form.component.d.ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the dependency (demo-lib) which declares DemoFormComponent has not been processed correctly by ngcc.

4 export declare class DemoFormComponent implements OnInit {
                       ~~~~~~~~~~~~~~~~~

Can anyone please help me with this issue?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can only import modules into you module. You cannot (and don't need to) import components.

Your library module exports the component. That is enough for Angular to find the component when you use it in your application.

import { DemoLibModule } from 'demo-lib'
.
.
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    DemoLibModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda