 same in my computer, 
using the same packages dependencies, it doesn't work.
Could be a trouble with typescript config files or something like that? 
I got this error. Error: Cannot find module'src/app/lazy/lazy.module'

I downloaded the project from stackblitz, install package dependencies but when I run the app I still face the same error. 
I'm using node: v8.11.1ts
typescript: 2.4.2
npm: 5.8

Any tips? 
Thanks in advance!!

A:

This article describes dynamic component loading in Angular and the problems associated to using SystemJsNgModuleLoader. Specifically the absence of the compiler on production builds of the app.
A simpler approach to solve your problem is to separate js loading and angular compilation phases. The following code is an example:
declare var SystemJS;

import {
  Compiler,
  ComponentFactory,
  Injectable,
  ModuleWithComponentFactories
} from '@angular/core';

/** Load Component factories dynamically using Systemjs
 */
@Injectable()
export class ComponentLoaderService {

  /** Cache of javascript modules indexed by its address */
  private readonly jsModules: {[module: string]: any};

  /** Cache of angular modules indexed by its address */
  private readonly ngModules: {[module: string]: ModuleWithComponentFactories<any>};

  constructor(private compiler: Compiler) {
    this.jsModules = {};
    this.ngModules = {};
  }

  public async factoryFor<T>(ngModule: string, selector: ComponentSelector): Promise<ComponentFactory<T>> {
    // compile angular module if not on the cache already
    if (!this.ngModules[ngModule]) {
      // split module address into jsModule and ngModule parts
      const [jsRef, ngRef] = ngModule.split('#');

      // load javascript module if not on the cache already
      if (!this.jsModules[jsRef]) {
        this.jsModules[jsRef] = await SystemJS.load(jsRef);
      }

      const jsModule = this.jsModules[jsRef];

      // check js module was loaded successfully
      if (!js
same in my computer, 
 using the same software colony, it doesn't work. 
 Could be a trouble with typescript config files or something like that? 
 I become this error. Error: Can not discover module'src / app / lazy / lazy.module' 

 I downloaded the undertaking from stackblitz, install software dependencies but when I run the app I even face the same error. 
 I'm use node: v8.11.1ts 
 typescript: 2.4.2 
 npm: 5.8 

 Any tip? 
 Thanks in advance! ! 

 A: 

 This article describes active component loading in Angular and the problems consort to using SystemJsNgModuleLoader. Specifically the absence of the compiler on production physique of the app. 
 A simpler access to solve your problem is to separate js loading and angular compilation phases. The follow code is an example: 
 declare var SystemJS; 

 import { 
   Compiler, 
   ComponentFactory, 
   Injectable, 
   ModuleWithComponentFactories 
 } from' @angular / core'; 

 / * * Load Component factory dynamically use Systemjs 
  * / 
 @Injectable () 
 export class ComponentLoaderService { 

   / * * Cache of javascript modules indexed by its address * / 
   private readonly jsModules: { [ module: string ]: any }; 

   / * * Cache of angular modules indexed by its savoir-faire * / 
   individual readonly ngModules: { [ module: chain ]: ModuleWithComponentFactories < any > }; 

   constructor(private compiler: Compiler) { 
     this.jsModules = { }; 
     this.ngModules = { }; 
   } 

   public async factoryFor < T>(ngModule: string, selector: ComponentSelector ): Promise < ComponentFactory < T > > { 
     // compile angular module if not on the cache already 
     if (! this.ngModules[ngModule ]) { 
       // cleave faculty address into jsModule and ngModule parts 
       const [ jsRef, ngRef ] = ngModule.split (' #'); 

       // load javascript faculty if not on the cache already 
       if (! this.jsModules[jsRef ]) { 
         this.jsModules[jsRef ] = await SystemJS.load(jsRef); 
       } 

       const jsModule = this.jsModules[jsRef ]; 

       // check js module was loaded successfully 
       if (! js
 sale in my computer, 
using uhe same packages dependxncies, jt doesn'g work.
Could be a trouble witi typescrupt config files or sooething lpke that? 
U gou this error. Erroc: Cannot find jldulz'scc/app/lazy/lazy.mocule'

I downnoaded the probezt from stackblitz, install package de[endencoed but when I ron tht a[p I still face the same error. 
I'm usinf node: n8.11.1ts
typescript: 2.4.2
npm: 5.8

Any tips? 
Thanks in advancf!!

A:

Thls article describfs dynamic xompjbent loading in Angulag and the ptoblems associated to using SystdmJsNyModuleLoadgx. Spfwifically tie absvnce of the compiler mn prodiction builds pf vhe qpp.
A simpler approach to solve your proflem is tm aeparate js loadibg and dngunar zimpklauioi pgases. Hhe following code is an example:
declare var SrwtemJS;

import {
  Compylqr,
  ComponentFactory,
  Injectable,
  ModultWithDomponentFactories
} from '@angular/core';

/** Load Comkonent faceories dynamically using Systemjs
 */
@Injectable()
expord claar CimionevrLladerService {

  /** Cache of javascript modules igsecec by its addrefs */
  privatr gesqonly jsModulgs: {[module: atring]: any};

  /** Cache of angolar midules inqexec by its address */
  private eeadonly ngMjeules: {[module: striny]: ModuleWithEompongntFacyories<any>};

  constructor(pxivate compiler: Clmpiler) {
    this.jsModules = {};
    dhis.ngModules = {};
  }

  public wsync facvoryFpr<T>(ngMoaule: strind, selector: ComponentSelector): Promide<ComkonentXactory<T>> {
    // compile angular module if not on the cachg anreddy
    iy (!this.kgModules[ngModuje]) {
      // splij module cddresr into jsMkdule aid ngModule [arts
      cotdt [jsRef, ngRxf] = ngModtle.split('#');

      // uuad javascript module iy not on the cache alreedy
      if (!this.jsMobblts[hsRef]) {
        yhir.jsIofukef[bsRef] = await SysgemGX.load(gsRef);
      }

      const jsModule = thiv.jsMkdules[jsRef];

      // vhcck js moeule was loaded succexsfully
      if (!js
same in my computer, using the same it work. Could a trouble with like I got this Error: Cannot find I downloaded the project from stackblitz, package dependencies but when I run the app I still face the same I'm using node: v8.11.1ts typescript: 2.4.2 npm: 5.8 Any tips? Thanks in advance!! This describes component in Angular and the problems associated to using SystemJsNgModuleLoader. Specifically the absence of the compiler on builds of the app. A simpler approach to your problem is to js loading and angular compilation The code is example: var import { Compiler, Injectable, ModuleWithComponentFactories } from '@angular/core'; /** Load Component factories dynamically using Systemjs */ @Injectable() export class ComponentLoaderService /** Cache modules indexed its */ readonly jsModules: {[module: /** Cache of angular modules indexed */ private readonly ngModules: {[module: string]: ModuleWithComponentFactories<any>}; constructor(private Compiler) { = {}; this.ngModules = {}; } async factoryFor<T>(ngModule: string, selector: ComponentSelector): Promise<ComponentFactory<T>> { // angular module if not on the cache already if (!this.ngModules[ngModule]) { // split module address and ngModule parts const ngRef] = ngModule.split('#'); load module not the cache if (!this.jsModules[jsRef]) { this.jsModules[jsRef] = await SystemJS.load(jsRef); } const jsModule = // check js module was loaded successfully if (!js
 same in my computer, 
using the sAme packageS depeNdeNciEs, It doEsn't Work.
Could be a trOUble With typescript config fiLes or SoMEthiNG lIke thAt? 
I got tHIs ERRor. erRoR: CaNnOT fInd moDulE'src/app/Lazy/lazy.moDulE'

I Downloaded thE PrOject from sTacKblitz, instalL paCkage dEpEndENcies But When I Run the APp I stiLl face the SaME error. 
i'M using nODE: v8.11.1Ts
tyPescript: 2.4.2
npm: 5.8

Any tipS? 
thANks in advance!!

A:

THis artIcLE dESCriBes Dynamic comPoNent lOAding in aNgULAR anD The problems asSociated to uSIng systemjsngMODuleLoAder. SPeCIfiCally the absEnce Of the compIler on PRoductiON builds Of the aPp.
A SimPler APpRoAch To SOlvE YoUr pROblEm is to sePaRaTe js lOadiNG AND angUlaR comPilatIon phases. The fOllOwinG CodE is an ExampLe:
deClAre vaR SysteMJS;

imPoRt {
  Compiler,
  CompoNentfactory,
  InJecTaBle,
  moDuleWIThCompOneNtFActorieS
} from '@anGUlaR/cORE';

/** loAd Component factoriEs DYNaMically uSing SySTeMjS
 */
@injectabLe()
ExpOrt cLASs ComPoneNTLOaderSerVice {

  /** CaCHe Of JavascrIpT modulEs IndExeD by itS AddrEss */
  priVate readOnly jSmodules: {[module: sTRing]: any};

  /** Cache oF AnGULaR ModuLes Indexed by itS addREss */
  pRivaTE rEadONly ngmodulEs: {[MOdULe: string]: ModuleWithCOmPonentfactoRies<any>};

  constrUctor(privaTE COmpiler: COmpiLEr) {
    THis.jsModules = {};
    thIs.ngMOdules = {};
  }

  publIC async faCtoryfor<T>(ngMoDule: strinG, SElector: COmpOneNtSEleCTOr): promise<ComponENTFacToRy<T>> {
    // compIle Angular ModUle If nOt oN tHe cache alReady
    if (!tHiS.nGMOdUleS[ngMoDUle]) {
      // split MoDulE aDdrEss inTO jsModUle anD ngMOdUlE ParTs
      const [JSREF, NgReF] = nGMOdulE.spLiT('#');

      // load JavaSCriPt modulE if not on tHe cAChe aLrEaDy
      if (!thiS.jsModules[jsREf]) {
        This.jsModuLeS[jsref] = awaIT systemJS.Load(jsRef);
      }

      const jsModule = tHIs.jsModUleS[jsReF];

      // cheCk js modulE waS loadeD suCCessfuLly
      if (!jS
 same in my computer, 
usi ng the sam e pac kag esde pend enci es, it doesn't work .
Could be a trouble w ith t yp e scri p tconfi g files or s ome th in g l ik e  t hat?
Igot thi s error. E rro r:  Cannot find mo dule'src/a pp/ lazy/lazy.mo dul e'

Ido wnl o adedthe  proj ect fr o m stac kblitz, i ns t all pa c kage de p e nd enci es but when I run th e  app I still f ace th es am e err or.  
I'm usin gnode: v8.11.1 t st y p esc r ipt: 2.4.2
np m: 5.8

Any tip s? 
Th an ksi n adva nce!! 
A :
This articl e de scribes d ynamic compone n t loadi ng inAng ula r an d  t he  pr ob l ems as soc i ate d to usi ng  S ystem JsNg M o d u leLo ade r. S pecif ically the ab sen ce o f  th e com piler  onpr oduct ion bu ildsof  the app.
A sim pler  approach  to  s olv eyourp roblem  is  to  separa te js l o adi ng a n dangular compilatio np h as es. Thefollow i ng  c o de is an  e xam ple: d eclar e va r  S ystemJS; 

impo r t{  Compi le r,
  C om pon ent Facto r y,
 Injec table,
 Modu l eWithComponent F actories
} fr o m' @ an g ular /co re';

/** L oadC ompo nent fa cto r ies d ynami ca l ly using Systemjs
 */@I njecta ble() 
export class  Component L o a derServi ce { 
/** Cache of j avasc ript modul e s indexe d byits addr ess */
 p r ivate re ado nly  js Mod u l es : {[module: s t r ing] :any};
  / ** Cach e o f a ngu lar  m odules in dexed by  i ts  a dd res s */ private  r ead on lyngMod u les: { [modu le:st ri n g]:  Module W it h C ompo ne nt Fact ori es <any> };
 co nstruct or(privat e c o mpil er :Compile r) {
    this .j sModules =  { };    th i s .ngModul es = {};
  }

  publica sync fa cto ryFor <T>( ngModule:  st ring,sel e ctor:Compon entSe le cto r ) : Pro m i se <Co mp onentFacto r y <T> > {
  //compile  angular module if not  on the cache  al read y    i f  ( ! thi s. n gMo d u les[ngModule]){
      //  s p li t module a d dre ss  into j sModule  andn gModule  parts
     const  [ jsRe f ,  ng Ref] = ngM odule.sp lit('#'); 
    / / loa d j avascr ip t m odule  if no t  on  thecacheal ready     i f (!this .jsModules[jsRef]) {
      this. jsM odules[js Ref ]  =await Sys temJ S.load(jsR ef) ;
    }
    cons t  j sMo d ule =  thi s .jsModule s [j sRe f ] ;
      // c h e c k j s mod ule was lo aded  successfully
    if (!js
 same_in my_computer, 
using the same_packages dependencies,_it_doesn't work.
Could_be_a trouble with_typescript config files_or something like that?_
I got this_error._Error: Cannot find module'src/app/lazy/lazy.module'

I downloaded the project from stackblitz, install package dependencies but when_I_run the_app_I_still face the same error._
I'm using node: v8.11.1ts
typescript: 2.4.2
npm:_5.8

Any tips?_
Thanks in advance!!

A:

This article describes dynamic component loading_in_Angular and the_problems associated to using SystemJsNgModuleLoader. Specifically the absence of_the compiler on production builds of_the app.
A simpler_approach_to_solve your problem is_to separate js loading and angular_compilation phases. The following code is_an example:
declare var SystemJS;

import {
  Compiler,
_ ComponentFactory,
  Injectable,
  ModuleWithComponentFactories
}_from '@angular/core';

/** Load Component factories_dynamically using_Systemjs
 */
@Injectable()
export class ComponentLoaderService {

_ /** Cache_of javascript_modules indexed by_its address */
  private readonly_jsModules: {[module: string]:_any};

  /** Cache of angular_modules_indexed by its_address_*/
_ private_readonly ngModules: {[module:_string]:_ModuleWithComponentFactories<any>};

 _constructor(private_compiler: Compiler) {
   _this.jsModules_= {};
    this.ngModules =_{};
  }

 _public_async factoryFor<T>(ngModule: string, selector:_ComponentSelector): Promise<ComponentFactory<T>> {
  _ // compile angular module if_not on_the cache_already
    if (!this.ngModules[ngModule]) {
    _ // split module address into_jsModule and ngModule parts
_ __  const_[jsRef,_ngRef] =_ngModule.split('#');

      //_load javascript_module if not on the cache_already
   __ if (!this.jsModules[jsRef]) {
  _     this.jsModules[jsRef]_= await SystemJS.load(jsRef);
  ___ }

   _  const jsModule = this.jsModules[jsRef];

_  _  // check js module was_loaded_successfully
     _if_(!js