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?
Happens for me too. These are the versions of my project:
@angular/cli: 1.1.3
node: 6.11.0
os: darwin x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3
@angular/compiler-cli: 4.2.4
@angular/language-service: 4.2.4
I solved it setting the zone.js version to 0.8.14. I don't know if we have an issue on Angular-CLI or on zone.js.
I did a successful ng build -prod a couple of hours ago, but now I get the same error without changing nothing to my project.
@marius-oprea same thing just happened to me.
I'm getting the same error too. Updating zone.js did not work for me.
Happening here as well. Very odd. Tried messing around with a lot of different versions of Angular, Angular CLI, Zone.js and others with no luck.
Same here, tried updating zone.js and it did not work
We eventually solved it by mass updating our node packages. Not sure which one solved the problem, wasn't zone.js though.
@bcravens can you share your package.json?
updating to @angular/cli 1.2.4 and the other packages to the latest version solved the issue for me.
Change your package.json to zone.js: 0.8.14. Delete node_modules folder and run npm install again.
Updating to @angular-cli: 1.2.4 fixed the issue for me.
The patch rc.1 was released to address this, but others still indicate problems with rc.1 here: #7113. rc.1 fixed most of my apps, but for some sample projects I was using a tsconfig with 'include: []', relying on ng to pass my entrypoint to the compiler. When using AOT you will get this error even in rc.1 unless you include the entry points explicitly in tsconfig.
None of the package updating worked for me but adding enhanced-resolve: 3.3.0 did. See #4551
@angular/cli: 1.2.4 fix the problem
@angular/cli: 1.2.4 fixed the problem for me also - this on VSTS Hosted
Getting the same error. CLI 1.2.4 and Zone 0.8.14 did not resolve the problem for me
Updating to @angular/cli: 1.2.4 also fixed the problem for me.
If updating to 1.2.4 doesn't work for you. Make sure you remove your node_modules folder and your package-lock.json, and run npm install. And if even that doesn't work, install [email protected], to avoid installing the faulty package. And if that doesn't work, you should probably be looking at your own code :)
Oh, @PierreDuc It would be nice, if you were right...
Everything updated/removed/installed, enhanced-resolve too... but after all of this I can run only ng build --aot without any Can't resolve 'src\$$_gendir\... bug. When I run ng commands with i18n option (it can be serve or build like ng serve --aot --locale sk --i18n-file locale/messages.sk.xmb --i18n-format xmb), I get Can't resolve './$$_gendir/app/app.module.ngfactory' ... and I'm pretty sure this is not due to my code :(