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

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

Got the same problem here

1 Like

I have found a solution that worked for me. In src/declarations.d.ts I had only

declare module ‘lodash’;

I have ovewritted by

declare module ‘*’;

And then I have been able to execute “ionic build android” successfully.

3 Likes

Same problem (RC3): ionic serve works fine, but ionic build fails with that same message.

1 Like

Updating/adding the src/declarations.d.ts worked for me. tnx @mcrespi

Please remove the ^ character from your package.json file as mentioned here.

1 Like

Another issue might be the Typescript version. Latest version (2.1.x) is not yet compatible with Angular/Ionic. This causes the same error. Try using 2.0.x.

2 Likes

as mentioned by @jose2007kj post, it helped me to resolve the issue. But frankly same code base in other folder with “^” in package.json is working. weird

thanks, you saved me!

What fixed the error?

Make sure to install angular-cli