ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
I am getting ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' when I run ng build --prod, but if I run the command ng build --env=prod I get success.
Do we have any differences between these commands?
@atiris Are you running on linux or windows? For some reason enhanced-resolve: 3.3.0 fixes it for my on windows, but not on linux. It's the same version of npm and node on both machines.
@atiris Have you cleared your npm cache, and removed the angular-cli global package?
@PierreDuc I do my complete procedure again just now:
cd <project>;
delete node_modules;
delete package-lock.json;
npm uninstall @angular/cli -g;
npm cache clean --force; (last time I run only npm cache verify)
npm install @angular/cli -g;
npm cache verify;
close / open console;
cd <project>;
npm install;
ng --version; (result: 1.2.4)
ng build --aot; (result: many errors type Can't resolve './$$_gendir/app/app.module.ngfactory')
checked package.json --> dependencies already contains "enhanced-resolve": "^3.3.0" but I run also next command
npm install [email protected] --save;
ng build --aot; (result: now everything is OK)
ng build --aot --locale sk --i18n-file locale/messages.sk.xmb --i18n-format xmb; (result: again the same error, but only one)
ERROR in Unsupported
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '<project>\src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
@flauc I run it on windows. My actual versions:
@angular/cli: 1.2.4, node: 8.1.3, npm: 5.3.0, os: win32 x64
@angular/animations, @angular/common, @angular/compiler, @angular/core, @angular/forms,
@angular/http, @angular/platform-browser, @angular/platform-browser-dynamic,
@angular/platform-server, @angular/router, @angular/upgrade, @angular/compiler-cli,
@angular/language-service: 4.3.1
@filipesilva
I am also having the same problem,
Tried all solutions mentioned above
- Using latest
rc1 - installed
[email protected]still the same error.
The project is newly generated by the command
ng new my-prj --skip-install --skip-git -dir my-prj --style scss --routing
@angular/cli: 1.2.4 fix the problem, but can't ng build --prod --aot, I got
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
The last fine build was done before angular 4.3
Same issue here... only fix for me seems to be changing build script to use --env=prod instead of --prod. Updating @angular/cli and other packages didn't make a difference.
Heya, please see https://github.com/angular/angular-cli/issues/7113#issuecomment-317523744 for this issue.
Updating to @angular/[email protected] and [email protected]
Then
remove node_modules directory
npm cache clear
npm install
fixed the issue with ng build --prod
Hi @filipesilva, did you see that I used the latest angular cli 1.2.4 for test when I got this error here https://github.com/angular/angular-cli/issues/7125#issuecomment-317683022 ? How this https://github.com/angular/angular-cli/issues/7113#issuecomment-317523744 can help me, if I already use angular/[email protected]? Or changing angular cli is not the only thing i have to do according your message? I guess I just do not know what to do. Thank you in advance for the answer.
@atiris it looks like there might be another problem, related to --i18n only. Can you open a new issue where we can track it?
@filipesilva sure, here: https://github.com/angular/angular-cli/issues/7133
I can confirm that ng new project-name problem with "$$_gendir/app/app.module.ngfactory" can be resolved by:
npm install [email protected] --save;
ng build --prod --aot; (result: now everything is OK)
also ng build --prod its not this same as ng build --env=prod
Updating to @angular/cli: 1.2.4 worked for me!
We don't use @angular-cli (using webpack directly) and the same problem started happening last night. upgrading zone.js didn't help. Anybody have any idea?
@Iroitman try to delete the node_modules folder and package-lock.json file and then run npm install again!
@marciomsm I installed "enhanced-resolve": "3.3.0", and it helped. Note that "enhanced-resolve": "^3.3.0" failed (it picked 3.4.1, and this caused failure)
I also got this issue with @angular/cli 1.2.4. After working around, I found the reason from webpack package. You must delete folder enhanced-resolve in webpack/node_modules and run 'ng build --prod' again. It works with me. I think webpack is using the latest version 3.4.1 which does not work with Angular CLI.
Note: This is only temperate solution. We should wait for a fix of Angular CLI to force to use enhanced-resolve 3.3.0.
Updating to @angular/cli: 1.2.4 worked for me!
Make sure you are updating @angular/* to latest version ^4.2.4 Then delete node_modules and do npm install
I found there are difference between yarn & npm. With npm, webpack is installed but no dependency 'enhanced-resolve' is included With yarn, webpack is installed but dependency 'enhanced-resolve' 3.4.1 is included When run 'ng build --prod' with yarn packages, 'enhanced-resolve' 3.4.1 causes this issue.
#7136