ionic-framework: Module not found: Error: Can't resolve './app.module.ngfactory' ionic-angular 3.9.0
Ionic version: (check one with “x”) (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [ ] 3.x [ ] 4.x
I’m submitting a … (check one with “x”) [ ] bug report [ ] feature request
Please do not submit support requests or “How to” questions here. Instead, please use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
Module not found: Error: Can’t resolve ‘./app.module.ngfactory’ using description file: E:\Working Project\test\package.json (relative path: ./src/app) Field ‘browser’ doesn’t contain a valid alias configuration after using description file: E:\Working Project\test\package.json (relative path: ./src/app) using description file: E:\Working Project\test\package.json (relative path: ./src/app/app.module.ngfactory) no extension Field ‘browser’ doesn’t contain a valid alias configuration E:\Working Project\test\src\app\app.module.ngfactory doesn’t exist .ts Field ‘browser’ doesn’t contain a valid alias configuration E:\Working Project\test\src\app\app.module.ngfactory.ts doesn’t exist .js Expected behavior:
should build as per info Steps to reproduce:
Related code:
insert short code snippets here
Other information: this error comes with production tag only.
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
insert the output from ionic info here
@ionic/cli-utils : 1.17.0 ionic (Ionic CLI) : 3.17.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.1-201711071727
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.8.0-201711062059
System:
Android SDK Tools : 25.2.5
Node : v8.9.0
npm : 5.5.1
OS : Windows 10
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 55 (14 by maintainers)
Try run this command
$ ./node_modules/.bin/ngcIt will show the detail error part in your code, it saved my life trying to find what was causing the error. May this can help you.
Here are the general instructions that were sent around to testers and some early adopters that we asked to test out the next release:
~2.4.25.0.0@ionic/app-scriptstonightlyionic-angulartonightly@ionic/storageto2.1.3rxjsto5.5.2npm installDouble check that all of that was done on your project that is failing.
I have the same issue, removing
node_modules,package lock fileandwwwbuild folder doesn’t resolve for me the issue!It could be we have some providers or something else which at the moment we don’t have loaded in some module. But it would be impossible find the file on hundreds and hundreds of files
i downgraded angular from “5.0.0” to “4.4.4” it worked fine…just change the value of all angular dependencies in package.json and do npm install…hope it helps. Also make sure all pages you have are added to the Ng Module. Hack on!
I think I got it, the problem is there are several errors, with always the same error message and ionic serve does work always correct which is the BIG problem
if you have a look on this a) don’t have components, providers or directives in project which are not included in a module b) don’t use *directives which are not imported in module, there is no error message for that c) don’t import Modules in project which are not available, no error message d) refetor your rxjs to 5.5 e) check you lib if they are incompatible with ng5 most of the incompatibility is RxJS in ng5
Probably you think, all this point are for sure. But the big problem is most of the cases ionic serve run without error and in ionic build you have always the same error, so it is nearly impossible to find the errors, we take 2 days to discover all this errors.
All this errors can and can not be discovered by ionic serve, it depends on the combination of the errors. For example if there problems with directives the rxjs problems are not discovered.
I think I can reproduce this behavior also on an empty stupid new project
@thiagosantos I actually had to downgrade from
to
But the real problem I had came from the aot which seems to be unable to link something from the UI to the controller (such as a private value used in the template). To find them (commit your changes first) run
Then
Will show all the possible code errors.
I also had as suggested @kensodemann to upgrade rxjs to 5.5.2 and change:
I might have found the solution. Check on your directory tree if you have some pages / provider / etc that are not referenced in app.module. In my case, I still had the default pages/home folder, but I had deleted it from app.modules.ts I am still investigating on another app, I’ll give you further feedback.
Hi guys,
I had the same problem and this is how I resolve it:
And you will get the real errors. Note that after update Ionic to the latest version (which uses the latest version of Angular), you have to be careful with private and public variable declarations. I had the same issue with Angular aswell.
The most common issues that I had was problems about private and public declarations, and also when use NGRX I cant export reducers using arrow functions, I’ve to use the functions in old way, I mean:
Once you have all your issues, run
And it should work. Hope it helps.
Module not found: Error: Can’t resolve ‘./app.module.ngfactory’ ionic-angular
this error also occurs when import an angular-ionic page which having module.ts file as sibling. also do not import any ionic page which having @IonicPage() decorator.
In - app.module.ts
import {LoginPage} from ‘…/pages/login/login’; //wrong #having a module.ts file as sibling in source tree
also don’t add decorator as
@IonicPage() //wrong – this is only for lazy loading @Component({ selector: ‘page-login’, templateUrl: ‘login.html’, }) export class UserdashboardPage {}
component that are to be loaded as lazy so don’t import them in app.module.ts
Hi there, For everyone running this issue take a look on Dan comment at https://github.com/ionic-team/ionic-app-scripts/issues/1309#issuecomment-343990321
This may help
We have too many open issues pertaining to this one issue. I am going to close this one (and others) and leave the following issue open: https://github.com/ionic-team/ionic-app-scripts/issues/1309
Reason: This particular issue list is for issues with the Ionic Framework itself. All of these issues so far seem to have two components:
--prodgives not exactly helpful error with--prodThe latter issue may have something to do with Ionic tooling, but may also have more to do with tooling further down the chain. That is being investigated, but that is more closely related to
@ionic/app-scriptswhich is why I am leaving that issue open.This just consolidates things so we are not discussing the same issue in several different threads.
Please follow up with further info here: https://github.com/ionic-team/ionic-app-scripts/issues/1309
i created a new project and started copy my files with plugins. updated rxjs as per 5.5.2. project is working till now. but when ever i install “npm install ionic2-auto-complete --save” component. it is creating the given issue to me. " Can’t resolve ‘./app.module.ngfactory’"
@matoos32 update these ones to latest 4.4.0.may it could work for you .ionic-native/core ionic-native/splash-screen ionic-native/status-bar
@kensodemann I had problem for 2 days, but I just had to refactor rxjs. I am almost certain that people don’t know how to do it. I spent today 6 hours refactoring code and made it work. I posted what I did here #2893
I’m getting the error too upgrading to Angular 5 and running
ionic build --prod. I also get the error using onlyionic build --aot. On the plus side, these are running successfully:ionic build --minifyjsionic build --minifycssionic build --optimizejsionic build --optimizejs --minifyjs --minifycssIs
--proda short-form for--aot --optimizejs --minifyjs --minifycss, or does it give you something extra?RE: @joeldavuk
I deleted all my project’s repo contents (safe for /.git/) and did a
git reset --hardto restore vanilla code. Also ensured package-lock.json was deleted. Did annpm installand thenionic build --prodcontinued to fail with the same error.RE: @bogomips
I inspected my app.module.ts vs. the project file-system and didn’t notice anything stale. Will keep an eye out, though.
package.json:
ionic info:
@morrisonbrett I started to copy, 1 to 1, every single file from my project to a new one. To a certain point (in the new project) I’ve got the error, it was generated from the pages/Home present on my src/ but never referenced on my app.modules (I had deleted it). I did not finish the process yet, 'cause in the meanwhile I am cleaning and refactoring some code, I am switching to lettable operators in rxjs, etc, etc Anyway, so far, I am compiling with --prod (in the new project) and everything works fine. My feeling is the in the older project has some dead folder not actually used but that in someway they are taken in consideration from the compiler that searches for all .ts files. I’ll be sure of it as soon as I finish this process, but I will address you guy to this direction. I hope I’ve been cleaner now.