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

The fix is only working on MacOS for me. I still get the error in my CI environment which runs the build --prod on a node:8.2 docker image based on debian. I updated to @angular/cli 1.2.4 and also fixed the version of enhanced-resolve to 3.3.0.

klawel avatar Jul 26 '17 09:07 klawel

ng build --env=prod

Just try this instead of ng build --prod

InsaneNaman avatar Jul 27 '17 17:07 InsaneNaman

--env=prod and --prod are not the same thing. Please see https://github.com/angular/angular-cli/issues/7113#issuecomment-317472732 for more information about it.

filipesilva avatar Jul 28 '17 09:07 filipesilva

Changing to "@angular/cli": "1.2.4" fixed the problem.

Make sure after changing from 1.0.0 ver to 1.2.4 to npm install before you ng build ...

vbozhinovski avatar Aug 09 '17 15:08 vbozhinovski

My version is:

@angular/cli: 1.0.1 node: 6.7.0 os: win32 x64 @angular/common: 4.3.4 @angular/compiler: 4.3.4 @angular/core: 4.3.4 @angular/forms: 4.3.4 @angular/http: 4.3.4 @angular/platform-browser: 4.3.4 @angular/platform-browser-dynamic: 4.3.4 @angular/router: 4.3.4 @angular/cli: 1.0.1 @angular/compiler-cli: 4.3.4 and @mihau1 comment solve my problem : https://github.com/angular/angular-cli/issues/7125#issuecomment-317723824

crsepulv avatar Aug 17 '17 15:08 crsepulv

My original version is 1.2.1 and @angular/cli: 1.2.4 fixed the problem~

howard9104 avatar Aug 20 '17 02:08 howard9104

This worked for me Step 1: Delete the node_modules folder Step 2: Replace your package.json "devDependencies": with the following;

"@angular/cli": "^1.3.1",
"@angular/compiler-cli": "^4.0.0",  
"@angular/language-service": "^4.0.0",
"@types/jasmine": "2.5.45",
"@types/jquery": "^3.2.11",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"

Step 3; Run npm install

kingsolo50 avatar Aug 23 '17 01:08 kingsolo50

same issue here, but using --env=prod solves the problem, anyways I would like to know what is causing this error

dgroh avatar Aug 28 '17 13:08 dgroh

I could fix the issue by running the following commands:

  1. npm install -g @angular/cli@latest
  2. npm install --save-dev @angular/cli@latest
  3. rimraf .\node_modules\
  4. ncu -u
  5. npm install
  6. npm cache clean

dgroh avatar Aug 28 '17 13:08 dgroh

Could someone told us about the source of this problem . because if i take my case , the command ng build --prod --aot was working fine . i don't change any thing on my project . and after a while . i have the same error ... updating the angular cli to the version 1.2.4 solve the problem for me . but still not getting what was the problem exactly ? . some help please .

yassinechabli avatar Sep 06 '17 13:09 yassinechabli

Note: Updating to angular-cli 1.2.4 solved the problem that started this thread for our instance of the installation.

Application development done both on Mac and Windows. Deploying to Apache / Docker containers.

Of course, we also needed to do a fresh npm install.

beauxjames-ZZ avatar Sep 06 '17 19:09 beauxjames-ZZ

Thank you @beauxjames , but i found anoher problem when updating to the 1.2.6 . some module in my application are not working . so what you think should i do ? trying to solve this problem and keep the version 1.2.6 of angular or downgrade it to the old version and solve it with another way .

yassinechabli avatar Sep 07 '17 08:09 yassinechabli

@yassinechabli I was able to solve it in multiple project with CLI 1.2.6 + Error you are getting now might be related to AOT, you can fix it if you follow the guidelines. What error you are getting, may be some one can help. Or search with that error messages separately and fix them.

achieverprince avatar Sep 12 '17 07:09 achieverprince

the problem was about a module (ngx-date-picker) that need to be updated also . i don't know why , but i upgrade to the last version with some modification in my code and it works . thank you @achieverprince .

yassinechabli avatar Sep 15 '17 08:09 yassinechabli

below command solved my issue npm install [email protected]

manishit56 avatar Sep 22 '17 15:09 manishit56

removing node_modules and running npm install worked for me.

justin48 avatar Oct 18 '17 21:10 justin48

Sloved !! I had this issue when i was trying the execute ng build -aot command. problem slove for me when i changed the version of "@angular/cli": "1.2.0" to "@angular/cli": "1.3.0",

devssharma avatar Nov 11 '17 11:11 devssharma

Sloved !! I had this issue when i was trying the execute ng build -prod command. Problem solved by updating the version of "@angular/cli": "1.0.0" to "@angular/cli": "1.3.0".

imichelakos avatar Nov 14 '17 18:11 imichelakos

None of the solutions worked for me, because the issue was about memory. Maybe the command below could work for those who couldn't find a solution. This solved the issue in my case.

node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod

scharlo avatar Feb 01 '18 18:02 scharlo

Could not resolve "./components/template/template.module" from "E:/vat_frontend/src/app/app.module.ts".

bharath005 avatar Apr 05 '18 07:04 bharath005