1

I have been asked to create a project in angular 4 while angular 5 is already in market. I have RND for several day to find out how to create an angular 4 project. Meanwhile, I have come to know that downgrading angular CLI will work for me. I did so and created a project which was really an angular 4 project. When I build my project for a production environment, I encounter an error which is listed below.

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'E:\typescript\lisleware\src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts

If any kindhearted person can help me in this matter then he/she will be appreciated.

2 Answers 2

1

You can try with other node or @angular/cli versions but this worked for me:

Node version: v8.4.0 (I use nvm)

$ npm install -g @angular/[email protected]
$ ng new test
$ cd test
$ ng serve

Then go to browser and type localhost:4200

If you view your package.json you can find:

 .....
  "dependencies": {
    "@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",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  }
.....
Sign up to request clarification or add additional context in comments.

5 Comments

I have created my angular application using same procedure you have mentioned in your answer above. However, I have used @angular/[email protected].
If you found a solution don't forget to post it. It will be helpful to community.
Sure I will. I am striking my head to find one for last some days.
I am thankful to you Mr. Jahuuar for your help. It really worked for me. I guess angular/cli version 1.3.2 is a stable one for angular 4.
Yes, 1.3.2 is the last version of @angular/cli 1.3. I also tried with some of 1.4 but got an error, I think it because node version also. You can view cli versions with "npm view @angular/cli". Don't forget to mark the answer as accepted if you are really thankful.
1

1 - Install NodeJS & Git Bash

2 - Got to your source-folder, RightClick --> Open Git Bash

3 - Give the Command $ npm install -g @angular/[email protected] in your git bash

4 - Give the Command ng new test in your git bash 4.1 - Better: Use ng g -routing test, a routing module is generated

5 - Move to the New Folder and open Git Bash there

6 - Use ng serve in your Git Bash

7 - Open localhost:4200

Here you go, have Fun!

1 Comment

Thank you for your answer to my question @DoMont. However, I have gone through all these procedures. I am able to create a project and everything, but when I am trying to build the project for the production using $ ng build --prod encountering the error which is in the question above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.