angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

Open marciomsm opened this issue 9 years ago • 67 comments

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?

marciomsm avatar Jul 24 '17 18:07 marciomsm

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

ajalmaguer avatar Jul 24 '17 19:07 ajalmaguer

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.

marciomsm avatar Jul 24 '17 19:07 marciomsm

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 avatar Jul 24 '17 19:07 marius-oprea

@marius-oprea same thing just happened to me.

bcravens avatar Jul 24 '17 19:07 bcravens

I'm getting the same error too. Updating zone.js did not work for me.

mattrichard avatar Jul 24 '17 20:07 mattrichard

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.

jh-code avatar Jul 24 '17 20:07 jh-code

Same here, tried updating zone.js and it did not work

ghost avatar Jul 24 '17 20:07 ghost

We eventually solved it by mass updating our node packages. Not sure which one solved the problem, wasn't zone.js though.

bcravens avatar Jul 24 '17 20:07 bcravens

@bcravens can you share your package.json?

ghost avatar Jul 24 '17 20:07 ghost

updating to @angular/cli 1.2.4 and the other packages to the latest version solved the issue for me.

marius-oprea avatar Jul 24 '17 20:07 marius-oprea

Change your package.json to zone.js: 0.8.14. Delete node_modules folder and run npm install again.

marciomsm avatar Jul 24 '17 20:07 marciomsm

Updating to @angular-cli: 1.2.4 fixed the issue for me.

ghost avatar Jul 24 '17 20:07 ghost

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.

EricABC avatar Jul 24 '17 21:07 EricABC

None of the package updating worked for me but adding enhanced-resolve: 3.3.0 did. See #4551

joseph-mcallister avatar Jul 24 '17 21:07 joseph-mcallister

@angular/cli: 1.2.4 fix the problem

tianyuanzhonglu avatar Jul 25 '17 03:07 tianyuanzhonglu

@angular/cli: 1.2.4 fixed the problem for me also - this on VSTS Hosted

philljones avatar Jul 25 '17 05:07 philljones

Getting the same error. CLI 1.2.4 and Zone 0.8.14 did not resolve the problem for me

dkro avatar Jul 25 '17 07:07 dkro

Updating to @angular/cli: 1.2.4 also fixed the problem for me.

nille85 avatar Jul 25 '17 07:07 nille85

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 :)

PierreDuc avatar Jul 25 '17 07:07 PierreDuc

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 :(

atiris avatar Jul 25 '17 09:07 atiris