Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!