[ts] Cannot find module './app.module.ngfactory'

Hi,

I am getting below in main.prod.ts Please help

[ts] Cannot find module ‘./app.module.ngfactory’.

2 Likes

I am getting the same error

I had this same error. Not sure this is the proper way to go about it, but I fixed this by adding an exclude to the tsconfig.json file:

“exclude”: [
“node_modules”,
“src/app/main.prod.ts”
],

I guess that that issue gonna be solve as soon as you will run “ionic build ios/android/etc.” and not “just” “ionic serve”

ionic serve -> compile and use main.dev.ts

ionic build … -> compile main.dev.ts, generate app.module.ngfactory, then compile and use main.prod.ts

But again it’s just a guess

I’m getting the same error and I upgraded npm and nodejs… I uninstalled and installed ionic as well

I can’t run ionic build after RC.0 upgrade

23:03:16] copy finished in 581 ms
[23:03:25] ngc error: Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 141:19 in the original .ts file), resolving symbol AppModule in /Users/dzheng/ionic/mapleapprc0/.tmp/app/app.module.ts
at simplifyInContext (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:469:23)
at StaticReflector.simplify (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:472:22)
at StaticReflector.annotations (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:61:36)
at _loop_1 (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:53:54)
at CodeGenerator.readFileMetadata (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:66:13)
at /Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:100:74
at Array.map (native)
at CodeGenerator.codegen (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:100:35)
at codegen (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/main.js:7:81)
at Object.main (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/tsc-wrapped/src/main.js:30:16)

[23:03:25] ngc error: Compilation failed

[23:03:25]

[23:03:25] bundle prod started …
[23:03:26] Error: Could not resolve entry (.tmp/app/main.prod.js)
at /Users/dzheng/ionic/mapleapprc0/node_modules/rollup/dist/rollup.js:8602:28

How does your app.module look like?
You need to rewrite your function to an export something like this: https://github.com/angular/angular/issues/11262

I also get this error but it is not stopping the app to build

It build but I got blank screen on IOS…

[11:30:31] ngc error: Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 143:19 in the original .ts file), resolving symbol AppModule in /Users/dzheng/ionic/mapleapprc0/.tmp/app/app.module.ts
at simplifyInContext (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:469:23)
at StaticReflector.simplify (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:472:22)
at StaticReflector.annotations (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/static_reflector.js:61:36)
at _loop_1 (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:53:54)
at CodeGenerator.readFileMetadata (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:66:13)
at /Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:100:74
at Array.map (native)
at CodeGenerator.codegen (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/codegen.js:100:35)
at codegen (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/compiler-cli/src/main.js:7:81)
at Object.main (/Users/dzheng/ionic/mapleapprc0/node_modules/@angular/tsc-wrapped/src/main.js:30:16)

[11:30:31] ngc error: Compilation failed

[11:30:31]

[11:30:31] bundle prod started …
[11:30:32] Error: Could not resolve entry (.tmp/app/main.prod.js)
at /Users/dzheng/ionic/mapleapprc0/node_modules/rollup/dist/rollup.js:8602:28

[11:30:32] sass started …
[11:30:35] sass finished in 2.82 s
[11:30:35] minify started …
[11:30:35] cleancss started …
[11:30:35] uglifyjs started …
[11:30:35] Error: ENOENT: no such file or directory, open '/Users/dzheng/ionic/mapleapprc0/www/build/main.js’
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.readFileSync (fs.js:508:33)
at addFile (/Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/node_modules/uglify-js/tools/node.js:68:22)
at /Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/node_modules/uglify-js/tools/node.js:79:17
at Array.forEach (native)
at Object.exports.minify (/Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/node_modules/uglify-js/tools/node.js:77:26)
at runUglifyInternal (/Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:34:19)
at runUglify (/Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:23:28)
at Object.uglifyjs (/Users/dzheng/ionic/mapleapprc0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:9:12)

[11:30:36] cleancss finished in 1.16 s
[11:30:36] minify finished in 1.17 s
[11:30:36] build prod finished in 11.51 s
Building project: /Users/dzheng/ionic/mapleapprc0/platforms/ios/MapleCity.xcodeproj

Here is my ngmodule

@NgModule({
  declarations: [
    .....
    
  ],
  imports: [
    IonicModule.forRoot(MapleApp, {
      tabPlacement: "bottom",
     
      platforms: {
        ios: {
          statusbarPadding: false

        },
      }
    }),
    CloudModule.forRoot(cloudSettings),
  
  ],
  bootstrap: [IonicApp],
  entryComponents: [
   ...
  ],
  providers: [
    Storage,
    UserData,
    MapleRestData,
    MapleConf,
    Connectivity,
    {
      provide: AuthHttp,
      useFactory: (http) => {
        return new AuthHttp(new AuthConfig({ noJwtError: true }), http);
      },
      deps: [Http]
    },
    AuthService,
    UpdateService],
})
export class AppModule { }

Try deleting .tmp folder and build again.

Try this:

export function authFactory(http: any) {
   return new AuthHttp(new AuthConfig({ noJwtError: true }), http);
}
@NgModule({ ....
 imports: [
 {
   provide: AuthHttp,
   useFactory: authFactory,
   deps: [Http]
  },
1 Like

Thanks! It fixed the error

I got the same error,

This is my app.module.ts

import { NgModule } from ‘@angular/core’;
import { IonicApp, IonicModule } from ‘ionic-angular’;
import { MyApp } from ‘./app.component’;
import { AboutPage } from ‘…/pages/about/about’;
import { HomePage } from ‘…/pages/home/home’;

import { LandingPage } from ‘…/pages/landingpage/landingpage’;
import { MainPage } from ‘…/pages/main/main’;
import { UniPage } from ‘…/pages/uni-page/uni-page’;

import {GeolocationService} from './…/providers/geolocation-service/geolocation-service’
import {ConnectivityService} from ‘./…/providers/connectivity-service/connectivity-service’;
import {DataService} from ‘./…/providers/data-service/data-service’;

import {LoadingModal} from ‘./…/components/loading-modal/loading-modal’;

@NgModule({
declarations: [
MyApp,
AboutPage,
MainPage,
HomePage,
LandingPage,
UniPage,
LoadingModal
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
MainPage,
HomePage,
LandingPage,
UniPage
],
providers: [GeolocationService, ConnectivityService, DataService]
})
export class AppModule {}

Please help me

Sorry, but I cannot see the function call like in the previous case so I need more detailed informations like stacktrace or something to be able to help.

when i ionic run android i got some error like this, please help me:

ngc error: can’t resolve module @angular/core/src/di/opaque_token from /Users/Rklumanlan/rc-0/.tmp/index.ts

[16:50:28] ngc error: TypeError: undefined is not a function
at ReflectorHost.findDeclaration (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/reflector_host.js:171:59)
at StaticReflector.initializeConversionMap (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/static_reflector.js:146:38)
at new StaticReflector (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/static_reflector.js:42:14)
at Function.CodeGenerator.create (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/codegen.js:142:31)
at codegen (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/main.js:7:36)
at Object.main (/Users/Rklumanlan/rc-0/node_modules/@angular/tsc-wrapped/src/main.js:30:16)
at Object. (/Users/Rklumanlan/rc-0/node_modules/@angular/compiler-cli/src/main.js:14:9)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)

[16:50:28] ngc error: Compilation failed

[16:50:28] NGC encountered an error

[16:50:28] bundle prod started …
[16:50:28] Error: Could not resolve entry (.tmp/app/main.prod.js)
at /Users/Rklumanlan/rc-0/node_modules/rollup/dist/rollup.js:8602:28
at runMicrotasksCallback (node.js:337:7)
at process._tickCallback (node.js:355:11)

[16:50:28] sass started …
[16:50:32] sass finished in 3.21 s
[16:50:32] minify started …
[16:50:32] cleancss started …
[16:50:32] uglifyjs started …
[16:50:32] Error: ENOENT, no such file or directory '/Users/Rklumanlan/rc-0/www/build/main.js’
at Error (native)
at Object.fs.openSync (fs.js:500:18)
at Object.fs.readFileSync (fs.js:352:15)
at addFile (/Users/Rklumanlan/rc-0/node_modules/uglify-js/tools/node.js:68:22)
at /Users/Rklumanlan/rc-0/node_modules/uglify-js/tools/node.js:79:17
at Array.forEach (native)
at Object.exports.minify (/Users/Rklumanlan/rc-0/node_modules/uglify-js/tools/node.js:77:26)
at runUglifyInternal (/Users/Rklumanlan/rc-0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:34:19)
at runUglify (/Users/Rklumanlan/rc-0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:23:28)
at Object.uglifyjs (/Users/Rklumanlan/rc-0/node_modules/@ionic/app-scripts/dist/uglifyjs.js:9:12)

[16:50:33] cleancss finished in 1.92 s
[16:50:33] minify finished in 1.92 s
[16:50:33] build prod finished in 10.64 s
Running command: /Users/Rklumanlan/rc-0/hooks/after_prepare/010_add_platform_class.js /Users/Rklumanlan/rc-0

The same was happening to me.
Installing Node.js 4.6.0 solved the problem

Hi, try changing your providers/custom component from

import {GeolocationService} from ‘./…/providers/geolocation-service/geolocation-service’

to

import {GeolocationService} from ‘./…/providers/geolocation-service’

for some reason subfolders in providers and customs dont get correct path in build.

That happened in my app, hope it helps.

Hi, i’m facing the same issue. But with ionic rc2. is there any working solution?

2 Likes

I have the same issue in rc3. Someone can help me?

1 Like