I am trying to npm install ngtools/[email protected] Module not found: Error: Can't resolve 'module.ngfactory.ts'

384 Views Asked by At

I am using angular version 4.1.0 with webpack using ngtools/[email protected] getting error module not found . i am getting these error using this ngtools/[email protected]

   Module not found: Error: Can't resolve
     './app/app.browser.module.ngfactory' in package.json (relative path:
     ./src/client)
         Field 'browser' doesn't contain a valid alias configuration   after using description file:  (relative path: ./src/client)
         using description file: package.json (relative path: ./src/client/app/app.browser.module.ngfactory)


     Error: . lazy Module not found: Error: Can't resolve
     '/media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack/src/client/app/modules/checkout-module/checkout.module.ngfactory.ts'
     in '/media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack'
     resolve '/media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack/src/client/app/modules/checkout-module/checkout.module.ngfactory.ts'
     in '/media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack'
     using description file: /media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack/package.json
     (relative path: .)
         Field 'browser' doesn't contain a valid alias configuration   after using description file: /media/ongraph/new volume
     1/EponymAngularproject/development/28junIE-angularuniversal/classicspecs-webpack/package.json
     (relative path: .)
         using description file: /media/ongraph/new volume           1/EponymAngularproject/development/28junIE-  angularuniversal/classicspecs-webpack/package.json
     (relative path:
     ./src/client/app/modules/checkout-module/checkout.module.ngfactory.ts)
     no extension
      Field 'browser' doesn't contain a valid alias configuration
      .module.ngfactory.ts doesn't exist
     @ . lazy  @ ./~/@angular/core/@angular/core.es5.js  @ ./~/@angular/platform-browser/@angular/platform-browser.es5.js  @
     ./src/client/main-browser.ts

When i change the version ngtools/webpack@~1.5.0 npm install succesfully. but it gives error after serve in console

Uncaught Error: No NgModule metadata found for 't'.
    at t.resolve (app.a3216cb….bundle.js:1)
    at t.getNgModuleMetadata (app.a3216cb….bundle.js:1)
    at t._loadModules (app.a3216cb….bundle.js:1)
    at t._compileModuleAndComponents (app.a3216cb….bundle.js:1)
    at t.compileModuleAsync (app.a3216cb….bundle.js:1)
    at e._bootstrapModuleWithZone (app.a3216cb….bundle.js:1)
    at e.bootstrapModule (app.a3216cb….bundle.js:1)
    at r (app.a3216cb….bundle.js:1)
    at Object.r [as a] (app.a3216cb….bundle.js:1)
    at Object.311 (app.a3216cb….bundle.js:1)

 "@angular/common": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/platform-browser-dynamic": "~4.1.0",
    "@angular/platform-server": "~4.1.0",
2

There are 2 best solutions below

0
On

Try to disable the AoT Compilation, this error is generic and it happens sometimes when AoT is enabled (by default the AoT is enabled on target production).

0
On

It is a bug in angular universal using ng-seed i have install package "enhanced-resolve": "3.3.0" in package.json. its working fine for me.