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

192
Vistas
Angular 2 Error when ng build AOT + lazy loading from different package

I have an angular 2 app that is the main entry for my application.

In this app I'm installing another angular npm package that has all the code for my modules.

This npm package is compiled like a angular library using AOT and its published to a private npm.

Here is a sample app with the errors. https://github.com/chorew/AngularSample

To see the problem:

  1. clone the repo
  2. npm install
  3. npm run dev:library

In the main app module I have this lazy loaded route:

const routes: Routes = [
    {   path: 'underwriting',
        loadChildren: '@h2o/underwriting/src/underwriting/underwriting.module#UnderwritingModule' 
    }
];

The error appears when i run the ng build --aot in the main app.

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve 'C:\Users\Juan.Pablo\projects\POC\h2o.web\packages\h2o.app\src\node_modules\@h2o\underwriting\src\underwriting\underwrit
ing.module.d.ngfactory.ts' in 'C:\Users\Juan.Pablo\projects\POC\h2o.web\packages\h2o.app\src\$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

It seams that the package name @h2o/underwriting is not properly translated into the path and since its the base for the module path it produces that error.

ng build is trying to find (check the extra src, like if the module is inside the main app src)

'C:\Users\Juan.Pablo\projects\POC\h2o.web\packages\h2o.app\src\node_modules\@h2o\underwriting\src\underwriting\underwrit
ing.module.d.ngfactory.ts'

when it should be

'C:\Users\Juan.Pablo\projects\POC\h2o.web\packages\h2o.app\node_modules\@h2o\underwriting\src\underwriting\underwrit
ing.module.d.ngfactory.ts'
about 4 years ago · Santiago Trujillo
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