Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda